RTP 发送PS流工具(已经开源)
生活随笔
收集整理的這篇文章主要介紹了
RTP 发送PS流工具(已经开源)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
RTP接收和發(fā)送程序
????實時傳輸協議一直在構建之中,此次聽雨堂RTP程序增加了一個PS流發(fā)送,以便于GB28181 程序作為測試。
????對RTP協議的理解越深,越想自己建立一個實時傳輸協議。
程序界面還是比較粗糙的,等我更新吧,如果做一個界面,可能還是使用QT,因為界面比較繁復,所以暫時沒有做這個的打算,還是先使用MFC來做這個。
發(fā)送程序
接收程序
增加了幾個選項,目前實現了ps流的發(fā)送。
代碼地址
https://gitee.com/guanzhi0319/rtp。
ps流的發(fā)送
CString audio_device_id = audio_device_index_[cb_select_audio_.GetCurSel()];CString video_device_id = video_device_index_[cb_select_video_.GetCurSel()];CWnd *pWnd = GetDlgItem(IDC_VIDEO_PRIVIEW);CRect rc;pWnd->GetClientRect(&rc);CString tmp_str;edit_ip_.GetWindowText(tmp_str);std::string ipaddress = CStringA(tmp_str).GetString();edit_port_.GetWindowText(tmp_str);int port = _ttoi(tmp_str);live_ts_encoder_ = new LiveRTPUdpEncoder(audio_device_id, video_device_id, 640, 480, (OAHWND)pWnd->GetSafeHwnd(), rc.right, rc.bottom, ipaddress,port);live_ts_encoder_->setStreamType(0);live_ts_encoder_->Start();其中setStreamType是最近修改的主要內容,可以設置成為以下幾種方式發(fā)送,注意還沒有寫完,目前實現了rtp ovre udp , ps rtp over udp
typedef enum en_stream_type {en_rtp,en_ts_over_rtp,en_ps_over_rtp,en_rtmp,en_rtsp }en_stream_type; void LiveRTPUdpEncoder::OnCaptureVideoBuffer(uint8_t *data, int len, unsigned int timestamp, bool isKeyframe) { #define D(x) *(data+x)if (SimpleThread::IsStop()) return;#if 0char buffer[32];sprintf_s(buffer, "QB:%02x %02x %02x %02x %02x %02x",D(0), D(1), D(2), D(3), D(4), D(5));OutputDebugStringA(buffer);return; #endifuint8_t* odata = NULL;int olen = 0;uint8_t n = D(4) & 0x1f;int isIFrame = n == 0x07;switch (v_stream_type){case en_rtp:odata = data;olen = len;break;case en_ps_over_rtp:uint8_t* odata;int olen;v_ps.packagingPs(isIFrame, timestamp, data, len, &odata, &olen);break;}//timestamp = GetTimestamp();{Lock lock(this);v_rtp.send_video(odata, olen, convertToRTPTimestamp(), isKeyframe);if (!gVideoBegin)gVideoBegin = true;}if (v_stream_type == en_ps_over_rtp)delete[]odata; }需要修正的:
1 程序啟動先把攝像頭打開,可以直接顯示
2 在沒有攝像頭的情況下,可以把窗口直播出去。
以上兩點會在近期更新
需要增加的
1 需要增加rtmp發(fā)送和rtsp發(fā)送。
2 接收程序增加存儲到磁盤IO的功能,以利于調試。
總結
以上是生活随笔為你收集整理的RTP 发送PS流工具(已经开源)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《算法导论3rd第一章》算法在计算中的作
- 下一篇: 2021-11-15 cv2.erode