使用jrtplib发送和接收网络流支持解码、播放


基于jrtplib实现了RTP发送和接收功能,支持发送H264、PS、TS等文件流,接收端读取发送端发来的数据后,取Payload数据,通过FFmpeg分离、解码出视频,将RGB格式的视频在窗口中显示。该代码对应我博客上的一篇文章:https://blog.csdn.net/zhoubotong2012/article/details/86502327
资源截图
代码片段和文件信息
// VideoDrawer.cpp: implementation of the CDDrawData class.
//
//////////////////////////////////////////////////////////////////////

#include “DDrawData.h“


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#define SAFE_RELEASE(p) { if ( (p) ) { (p)->Release(); (p) = 0; } }

CDDrawData::CDDrawData()
{
    m_pDD                = NULL;
    m_pddsFrontBuffer    = NULL;
    m_pddsBackBuffer     = NULL;

    m_dwWidth = 0;
    m_dwHeight = 0;
}

CDDrawData::~CDDrawData()
{
    Destroyobjects();
}

HRESULT CDDrawData::Init(HWND hWndRECT rect)
{
    HRESULT hr;

    // Cleanup anything from a previous call
    Destroyobjects();

    // DDraw stuff begins here

    if( FAILED( hr = DirectDrawCreateEx( NULL (VOID**)&m_pDD
                                         IID_IDirectDraw7 NULL ) ) )
        return E_FAIL;

    // Set cooperative level
    hr = m_pDD->SetCooperativeLevel( hWnd DDSCL_NORMAL );
    if( FAILED(hr) )
        return E_FAIL;
    
    DWORD dwWidthdwHeight;
    dwWidth = rect.right-rect.left;
    dwHeight = rect.bottom - rect.top;

 /*   RECT  rcWork;
    RECT  rc;
    DWORD dwstyle;

    // If we are still a WS_POPUP window we should convert to a normal app
    // window so we look like a windows app.
    dwstyle  = GetWindowstyle( hWnd );
    dwstyle &= ~WS_POPUP;
    dwstyle |= WS_OVERLAPPED | WS_CAPTION | WS_THICKframe | WS_MINIMIZEBOX;
    SetWindowLong( hWnd GWL_style dwstyle );

    // Aet window size
    SetRect( &rc 0 0 dwWidth dwHeight );

    AdjustWindowRectEx( &rc GetWindowstyle(hWnd) GetMenu(hWnd) != NULL
                        GetWindowExstyle(hWnd) );

    SetWindowPos( hWnd NULL 0 0 rc.right-rc.left rc.bottom-rc.top
                  SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );

    SetWindowPos( hWnd HWND_NOTOPMOST 0 0 0 0
                  SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );

    //  Make sure our window does not hang outside of the work area
    SystemParametersInfo( SPI_GETWORKAREA 0 &rcWork 0 );
    GetWindowRect( hWnd &rc );
    if( rc.left < rcWork.left ) rc.left = rcWork.left;
    if( rc.top  < rcWork.top )  rc.top  = rcWork.top;
    SetWindowPos( hWnd NULL rc.left rc.top 0 0
                  SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
*/
    GetWindowRect( hWnd &m_rcWindow );

    LPDIRECTDRAWCLIPPER pcClipper;
    
    // Create the primary surface
    DDSURFACEDESC2 ddsd;
    ZeroMemory( &ddsd sizeof( ddsd ) );
    ddsd.dwSize         = sizeof( ddsd );
    ddsd.dwFlags        = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

    if( FAILED( m_pDD->CreateSurface( &ddsd &m_pddsFrontBuffer NULL ) ) )
        return E_FAIL;

     if( FAILED( hr = m_pDD->CreateClipper( 0 &pcClipper NULL ) ) )
        return E_FAIL;

    if( FAILED( 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       7995  2014-03-10 15:46  yuvdisplay.cpp

     文件        904  2014-03-10 15:46  yuvdisplay.h

     文件      13969  2014-03-10 15:46  DDrawData.cpp

     文件       2169  2014-03-10 15:46  DDrawData.h

     文件       6431  2014-10-21 09:49  DecoderRtp.cpp

     文件       1073  2014-10-21 09:49  DecoderRtp.h

----------- ---------  ---------- -----  ----

                32541                    6


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)