RTP 发送PS流工具(已经开源)
RTP接收和發(fā)送程序
????實(shí)時(shí)傳輸協(xié)議一直在構(gòu)建之中,此次聽雨堂RTP程序增加了一個(gè)PS流發(fā)送,以便于GB28181 程序作為測試。
????對(duì)RTP協(xié)議的理解越深,越想自己建立一個(gè)實(shí)時(shí)傳輸協(xié)議。
程序界面還是比較粗糙的,等我更新吧,如果做一個(gè)界面,可能還是使用QT,因?yàn)榻缑姹容^繁復(fù),所以暫時(shí)沒有做這個(gè)的打算,還是先使用MFC來做這個(gè)。
發(fā)送程序
接收程序
增加了幾個(gè)選項(xiàng),目前實(shí)現(xiàn)了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是最近修改的主要內(nèi)容,可以設(shè)置成為以下幾種方式發(fā)送,注意還沒有寫完,目前實(shí)現(xiàn)了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 程序啟動(dòng)先把攝像頭打開,可以直接顯示
2 在沒有攝像頭的情況下,可以把窗口直播出去。
以上兩點(diǎn)會(huì)在近期更新
需要增加的
1 需要增加rtmp發(fā)送和rtsp發(fā)送。
2 接收程序增加存儲(chǔ)到磁盤IO的功能,以利于調(diào)試。
總結(jié)
以上是生活随笔為你收集整理的RTP 发送PS流工具(已经开源)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《算法导论3rd第一章》算法在计算中的作
- 下一篇: 2021-11-15 cv2.erode