1 origin: https://patches.libav.org/patch/39102/raw/
2 diff --git a/libmpdemux/demux_rtp.cpp b/libmpdemux/demux_rtp.cpp
3 index 018327c..4fa7efe 100644
4 --- a/libmpdemux/demux_rtp.cpp
5 +++ b/libmpdemux/demux_rtp.cpp
7 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
10 -#define RTSPCLIENT_SYNCHRONOUS_INTERFACE 1
13 // on MinGW, we must include windows.h before the things it conflicts
14 #ifdef __MINGW32__ // with. they are each protected from
15 @@ -94,15 +92,6 @@ struct RTPState {
17 extern "C" char* network_username;
18 extern "C" char* network_password;
19 -static char* openURL_rtsp(RTSPClient* client, char const* url) {
20 - // If we were given a user name (and optional password), then use them:
21 - if (network_username != NULL) {
22 - char const* password = network_password == NULL ? "" : network_password;
23 - return client->describeWithPassword(url, network_username, password);
25 - return client->describeURL(url);
29 static char* openURL_sip(SIPClient* client, char const* url) {
30 // If we were given a user name (and optional password), then use them:
31 @@ -126,6 +115,19 @@ int rtsp_transport_http = 0;
32 extern AVCodecContext *avcctx;
35 +static char fWatchVariableForSyncInterface;
36 +static char* fResultString;
37 +static int fResultCode;
39 +static void responseHandlerForSyncInterface(RTSPClient* rtspClient, int responseCode, char* responseString) {
40 + // Set result values:
41 + fResultCode = responseCode;
42 + fResultString = responseString;
44 + // Signal a break from the event loop (thereby returning from the blocking command):
45 + fWatchVariableForSyncInterface = ~0;
48 extern "C" int audio_id, video_id, dvdsub_id;
49 extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
50 Boolean success = False;
51 @@ -154,13 +156,19 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
52 rtsp_transport_http = demuxer->stream->streaming_ctrl->url->port;
53 rtsp_transport_tcp = 1;
55 - rtspClient = RTSPClient::createNew(*env, verbose, "MPlayer", rtsp_transport_http);
56 + rtspClient = RTSPClient::createNew(*env, url, verbose, "MPlayer", rtsp_transport_http);
57 if (rtspClient == NULL) {
58 fprintf(stderr, "Failed to create RTSP client: %s\n",
62 - sdpDescription = openURL_rtsp(rtspClient, url);
63 + fWatchVariableForSyncInterface = 0;
64 + rtspClient->sendDescribeCommand(responseHandlerForSyncInterface);
65 + env->taskScheduler().doEventLoop(&fWatchVariableForSyncInterface);
66 + if (fResultCode == 0)
67 + sdpDescription = fResultString;
69 + delete[] fResultString;
71 unsigned char desiredAudioType = 0; // PCMU (use 3 for GSM)
72 sipClient = SIPClient::createNew(*env, desiredAudioType, NULL,
73 @@ -244,8 +252,12 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
75 if (rtspClient != NULL) {
76 // Issue a RTSP "SETUP" command on the chosen subsession:
77 - if (!rtspClient->setupMediaSubsession(*subsession, False,
78 - rtsp_transport_tcp)) break;
79 + fWatchVariableForSyncInterface = 0;
80 + rtspClient->sendSetupCommand(*subsession, responseHandlerForSyncInterface, False, rtsp_transport_tcp);
81 + env->taskScheduler().doEventLoop(&fWatchVariableForSyncInterface);
82 + delete[] fResultString;
83 + if (fResultCode != 0) break;
85 if (!strcmp(subsession->mediumName(), "audio"))
87 if (!strcmp(subsession->mediumName(), "video"))
88 @@ -256,7 +268,11 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
90 if (rtspClient != NULL) {
91 // Issue a RTSP aggregate "PLAY" command on the whole session:
92 - if (!rtspClient->playMediaSession(*mediaSession)) break;
93 + fWatchVariableForSyncInterface = 0;
94 + rtspClient->sendPlayCommand(*mediaSession, responseHandlerForSyncInterface);
95 + env->taskScheduler().doEventLoop(&fWatchVariableForSyncInterface);
96 + delete[] fResultString;
97 + if (fResultCode != 0) break;
98 } else if (sipClient != NULL) {
99 sipClient->sendACK(); // to start the stream flowing
101 @@ -645,7 +661,8 @@ static void teardownRTSPorSIPSession(RTPState* rtpState) {
102 MediaSession* mediaSession = rtpState->mediaSession;
103 if (mediaSession == NULL) return;
104 if (rtpState->rtspClient != NULL) {
105 - rtpState->rtspClient->teardownMediaSession(*mediaSession);
106 + fWatchVariableForSyncInterface = 0;
107 + rtpState->rtspClient->sendTeardownCommand(*mediaSession, NULL);
108 } else if (rtpState->sipClient != NULL) {
109 rtpState->sipClient->sendBYE();