1. 程式人生 > >live555 實時音視訊(H264 & PCMA)

live555 實時音視訊(H264 & PCMA)

效果圖如下:




//-------------------------------------------------------------------------------------------------------------------------------------//

SDP日誌如下:

06-06 11:13:22.326: I/RTSPServer_jni(814): [RTSPServer.cpp:432 void RTSPServer::incomingConnectionHandler(int)]: accept()ed connection from 192.168.1.100

06-06 11:13:22.328: I/RTSPServer_jni(814): [RTSPServer.cpp:898 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: RTSPClientConnection[0x55618080]::handleRequestBytes() read 121 new bytes:OPTIONS rtsp://192.168.1.101:8554/1 RTSP/1.0
06-06 11:13:22.328: I/RTSPServer_jni(814): CSeq: 2
06-06 11:13:22.328: I/RTSPServer_jni(814): User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
06-06 11:13:22.328: I/RTSPServer_jni(814):
06-06 11:13:22.328: I/RTSPServer_jni(814): [RTSPServer.cpp:985 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: parseRTSPRequestString() succeeded, returning cmdName "OPTIONS", urlPreSuffix "", urlSuffix "1", CSeq "2", Content-Length 0, with 0 bytes following the message.
06-06 11:13:22.328: I/RTSPServer_jni(814): [RTSPServer.cpp:1124 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: sending response: RTSP/1.0 200 OK
06-06 11:13:22.328: I/RTSPServer_jni(814): CSeq: 2
06-06 11:13:22.328: I/RTSPServer_jni(814): Date: Tue, Jun 06 2017 03:13:22 GMT
06-06 11:13:22.328: I/RTSPServer_jni(814): Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
06-06 11:13:22.328: I/RTSPServer_jni(814):
06-06 11:13:22.364: I/RTSPServer_jni(814): [RTSPServer.cpp:898 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: RTSPClientConnection[0x55618080]::handleRequestBytes() read 147 new bytes:DESCRIBE rtsp://192.168.1.101:8554/1 RTSP/1.0
06-06 11:13:22.364: I/RTSPServer_jni(814): CSeq: 3
06-06 11:13:22.364: I/RTSPServer_jni(814): User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
06-06 11:13:22.364: I/RTSPServer_jni(814): Accept: application/sdp
06-06 11:13:22.364: I/RTSPServer_jni(814):
06-06 11:13:22.364: I/RTSPServer_jni(814): [RTSPServer.cpp:985 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: parseRTSPRequestString() succeeded, returning cmdName "DESCRIBE", urlPreSuffix "", urlSuffix "1", CSeq "3", Content-Length 0, with 0 bytes following the message.
06-06 11:13:22.502: I/RTSPServer_jni(814): [RTSPServer.cpp:1124 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: sending response: RTSP/1.0 200 OK
06-06 11:13:22.502: I/RTSPServer_jni(814): CSeq: 3
06-06 11:13:22.502: I/RTSPServer_jni(814): Date: Tue, Jun 06 2017 03:13:22 GMT
06-06 11:13:22.502: I/RTSPServer_jni(814): Content-Base: rtsp://192.168.1.101:8554/1/
06-06 11:13:22.502: I/RTSPServer_jni(814): Content-Type: application/sdp
06-06 11:13:22.502: I/RTSPServer_jni(814): Content-Length: 673
06-06 11:13:22.502: I/RTSPServer_jni(814):
06-06 11:13:22.502: I/RTSPServer_jni(814): v=0
06-06 11:13:22.502: I/RTSPServer_jni(814): o=- 1496717469771075 1 IN IP4 192.168.1.101
06-06 11:13:22.502: I/RTSPServer_jni(814): s=Session streamed by "RTSPServer"
06-06 11:13:22.502: I/RTSPServer_jni(814): i=1
06-06 11:13:22.502: I/RTSPServer_jni(814): t=0 0
06-06 11:13:22.502: I/RTSPServer_jni(814): a=tool:LIVE555 Streaming Media v2014.07.18
06-06 11:13:22.502: I/RTSPServer_jni(814): a=type:broadcast
06-06 11:13:22.502: I/RTSPServer_jni(814): a=control:rtsp://192.168.1.101:8554/1
06-06 11:13:22.502: I/RTSPServer_jni(814): a=range:npt=0-
06-06 11:13:22.502: I/RTSPServer_jni(814): a=x-qt-text-nam:Session streamed by "RTSPServer"
06-06 11:13:22.502: I/RTSPServer_jni(814): a=x-qt-text-inf:1
06-06 11:13:22.502: I/RTSPServer_jni(814): m=video 0 RTP/AVP 96
06-06 11:13:22.502: I/RTSPServer_jni(814): c=IN IP4 0.0.0.0
06-06 11:13:22.502: I/RTSPServer_jni(814): b=AS:500
06-06 11:13:22.502: I/RTSPServer_jni(814): a=rtpmap:96 H264/90000
06-06 11:13:22.502: I/RTSPServer_jni(814): a=fmtp:96 packetization-mode=1;profile-level-id=42C01E;sprop-parameter-sets=Z0LAHrkQFAe0IAAAAwAgAAAFEeLF1A==,aM48gA==
06-06 11:13:22.502: I/RTSPServer_jni(814): a=recvonly;
06-06 11:13:22.502: I/RTSPServer_jni(814): a=control:rtsp://192.168.1.101:8554/1/trackID=1
06-06 11:13:22.502: I/RTSPServer_jni(814): m=audio 0 RTP/AVP 97
06-06 11:13:22.502: I/RTSPServer_jni(814): c=IN IP4 0.0.0.0
06-06 11:13:22.502: I/RTSPServer_jni(814): b=AS:96
06-06 11:13:22.502: I/RTSPServer_jni(814): a=rtpmap:97 PCMA/8000
06-06 11:13:22.502: I/RTSPServer_jni(814): a=recvonly;
06-06 11:13:22.502: I/RTSPServer_jni(814): a=control:rtsp://192.168.1.101:8554/1/trackID=2
06-06 11:13:22.574: I/RTSPServer_jni(814): [RTSPServer.cpp:898 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: RTSPClientConnection[0x55618080]::handleRequestBytes() read 181 new bytes:SETUP rtsp://192.168.1.101:8554/1/trackID=1 RTSP/1.0
06-06 11:13:22.574: I/RTSPServer_jni(814): CSeq: 4
06-06 11:13:22.574: I/RTSPServer_jni(814): User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
06-06 11:13:22.574: I/RTSPServer_jni(814): Transport: RTP/AVP;unicast;client_port=59928-59929
06-06 11:13:22.574: I/RTSPServer_jni(814):
06-06 11:13:22.574: I/RTSPServer_jni(814): [RTSPServer.cpp:985 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: parseRTSPRequestString() succeeded, returning cmdName "SETUP", urlPreSuffix "1", urlSuffix "trackID=1", CSeq "4", Content-Length 0, with 0 bytes following the message.
06-06 11:13:22.585: I/RTSPServer_jni(814): [RTSPServer.cpp:1124 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: sending response: RTSP/1.0 200 OK
06-06 11:13:22.585: I/RTSPServer_jni(814): CSeq: 4
06-06 11:13:22.585: I/RTSPServer_jni(814): Date: Tue, Jun 06 2017 03:13:22 GMT
06-06 11:13:22.585: I/RTSPServer_jni(814): Transport: RTP/AVP;unicast;destination=192.168.1.100;source=192.168.1.101;client_port=59928-59929;server_port=6970-6971
06-06 11:13:22.585: I/RTSPServer_jni(814): Session: FE96A902;timeout=65
06-06 11:13:22.585: I/RTSPServer_jni(814):
06-06 11:13:22.593: I/RTSPServer_jni(814): [RTSPServer.cpp:898 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: RTSPClientConnection[0x55618080]::handleRequestBytes() read 200 new bytes:SETUP rtsp://192.168.1.101:8554/1/trackID=2 RTSP/1.0
06-06 11:13:22.593: I/RTSPServer_jni(814): CSeq: 5
06-06 11:13:22.593: I/RTSPServer_jni(814): User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
06-06 11:13:22.593: I/RTSPServer_jni(814): Transport: RTP/AVP;unicast;client_port=59930-59931
06-06 11:13:22.593: I/RTSPServer_jni(814): Session: FE96A902
06-06 11:13:22.593: I/RTSPServer_jni(814):
06-06 11:13:22.593: I/RTSPServer_jni(814): [RTSPServer.cpp:985 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: parseRTSPRequestString() succeeded, returning cmdName "SETUP", urlPreSuffix "1", urlSuffix "trackID=2", CSeq "5", Content-Length 0, with 0 bytes following the message.
06-06 11:13:22.596: I/RTSPServer_jni(814): [RTSPServer.cpp:1124 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: sending response: RTSP/1.0 200 OK
06-06 11:13:22.596: I/RTSPServer_jni(814): CSeq: 5
06-06 11:13:22.596: I/RTSPServer_jni(814): Date: Tue, Jun 06 2017 03:13:22 GMT
06-06 11:13:22.596: I/RTSPServer_jni(814): Transport: RTP/AVP;unicast;destination=192.168.1.100;source=192.168.1.101;client_port=59930-59931;server_port=6972-6973
06-06 11:13:22.596: I/RTSPServer_jni(814): Session: FE96A902;timeout=65
06-06 11:13:22.596: I/RTSPServer_jni(814):
06-06 11:13:22.628: I/RTSPServer_jni(814): [RTSPServer.cpp:898 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: RTSPClientConnection[0x55618080]::handleRequestBytes() read 156 new bytes:PLAY rtsp://192.168.1.101:8554/1 RTSP/1.0
06-06 11:13:22.628: I/RTSPServer_jni(814): CSeq: 6
06-06 11:13:22.628: I/RTSPServer_jni(814): User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
06-06 11:13:22.628: I/RTSPServer_jni(814): Session: FE96A902
06-06 11:13:22.628: I/RTSPServer_jni(814): Range: npt=0.000-
06-06 11:13:22.628: I/RTSPServer_jni(814):
06-06 11:13:22.628: I/RTSPServer_jni(814): [RTSPServer.cpp:985 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: parseRTSPRequestString() succeeded, returning cmdName "PLAY", urlPreSuffix "", urlSuffix "1", CSeq "6", Content-Length 0, with 0 bytes following the message.
06-06 11:13:22.629: I/RTSPServer_jni(814): [RTSPServer.cpp:1124 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: sending response: RTSP/1.0 200 OK
06-06 11:13:22.629: I/RTSPServer_jni(814): CSeq: 6
06-06 11:13:22.629: I/RTSPServer_jni(814): Date: Tue, Jun 06 2017 03:13:22 GMT
06-06 11:13:22.629: I/RTSPServer_jni(814): Range: npt=0.000-
06-06 11:13:22.629: I/RTSPServer_jni(814): Session: FE96A902
06-06 11:13:22.629: I/RTSPServer_jni(814): RTP-Info: url=rtsp://192.168.1.101:8554/1/trackID=1;seq=37075;rtptime=1897189058,url=rtsp://192.168.1.101:8554/1/trackID=2;seq=25069;rtptime=1038717352
06-06 11:13:22.629: I/RTSPServer_jni(814):
06-06 11:13:22.744: I/RTSPServer_jni(814): [RTSPServer.cpp:898 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: RTSPClientConnection[0x55618080]::handleRequestBytes() read 146 new bytes:GET_PARAMETER rtsp://192.168.1.101:8554/1 RTSP/1.0
06-06 11:13:22.744: I/RTSPServer_jni(814): CSeq: 7
06-06 11:13:22.744: I/RTSPServer_jni(814): User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
06-06 11:13:22.744: I/RTSPServer_jni(814): Session: FE96A902
06-06 11:13:22.744: I/RTSPServer_jni(814):
06-06 11:13:22.744: I/RTSPServer_jni(814): [RTSPServer.cpp:985 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: parseRTSPRequestString() succeeded, returning cmdName "GET_PARAMETER", urlPreSuffix "", urlSuffix "1", CSeq "7", Content-Length 0, with 0 bytes following the message.
06-06 11:13:22.745: I/RTSPServer_jni(814): [RTSPServer.cpp:1124 void RTSPServer::RTSPClientConnection::handleRequestBytes(int)]: sending response: RTSP/1.0 200 OK
06-06 11:13:22.745: I/RTSPServer_jni(814): CSeq: 7
06-06 11:13:22.745: I/RTSPServer_jni(814): Date: Tue, Jun 06 2017 03:13:22 GMT
06-06 11:13:22.745: I/RTSPServer_jni(814): Session: FE96A902
06-06 11:13:22.745: I/RTSPServer_jni(814): Content-Length: 10
06-06 11:13:22.745: I/RTSPServer_jni(814):
06-06 11:13:22.745: I/RTSPServer_jni(814): 2014.07.18
06-06 11:13:25.488: I/RTSPServer_jni(814): [RTSPServer.cpp:2145 static void RTSPServer::RTSPClientSession::noteClientLiveness(RTSPServer::RTSPClientSession*)]: RTSP client session (id "FE96A902", stream name "1"): Liveness indication
06-06 11:13:25.567: I/RTSPServer_jni(814): [RTSPServer.cpp:2145 static void RTSPServer::RTSPClientSession::noteClientLiveness(RTSPServer::RTSPClientSession*)]: RTSP client session (id "FE96A902", stream name "1"): Liveness indication
06-06 11:13:31.077: I/RTSPServer_jni(814): [RTSPServer.cpp:2145 static void RTSPServer::RTSPClientSession::noteClientLiveness(RTSPServer::RTSPClientSession*)]: RTSP client session (id "FE96A902", stream name "1"): Liveness indication
06-06 11:13:31.077: I/RTSPServer_jni(814): [RTSPServer.cpp:2145 static void RTSPServer::RTSPClientSession::noteClientLiveness(RTSPServer::RTSPClientSession*)]: RTSP client session (id "FE96A902", stream name "1"): Liveness indication

//-------------------------------------------------------------------------------------------------------------------------------------//


技術點:

1、live555實時資料處理(難點

2、G711編碼實現(同時實現AAC編碼)

3、音視訊時間戳的瞭解(後期做同步需要深入研究

4、VLC的日誌除錯

//-------------------------------------------------------------------------------------------------------------------------------------//

遇到的難點:

1、live555通過佇列取G711 ALAW編碼資料,資料發生變化導致VLC播放有雜音

 解決方案:

    查起來麻煩,擯棄佇列使用快取拷貝,VLC播放效果明顯變好

2、G711 ALAW編碼資料正常,live555推流結束後,VLC才播放開始幾包聲音資料

原因:VLC播放聲音原因時間戳

解決方案:在AudioFrameLiveSource::doGetNextFrame()中新增gettimeofday(&fPresentationTime,NULL);

3、單獨視訊流單獨音訊流VLC都播放正常。兩路流一起推,VLC黑屏聲音正常

原因:live555單執行緒機制,AudioFrameLiveSource::doGetNextFrame()和VideoFrameLiveSource::doGetNextFrame()兩個不能都有阻塞操作,出現上述現象是因為,AudiodoGetNextFrame獲取實時資料頻率高且有阻塞等待現象,導致視訊VideodoGetNextFrame也無法處理資料。

解決方案:目前機制AudiodoGetNextFrame獲取實時資料失敗不做等待且memcpy(fTo,audiodata,0),VideodoGetNextFrame仍阻塞獲取實時資料。效果不錯!