]>
Commit | Line | Data |
---|---|---|
1ee1ef52 JB |
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 | |
6 | @@ -19,8 +19,6 @@ | |
7 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
8 | */ | |
9 | ||
10 | -#define RTSPCLIENT_SYNCHRONOUS_INTERFACE 1 | |
11 | - | |
12 | extern "C" { | |
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 { | |
16 | ||
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); | |
24 | - } else { | |
25 | - return client->describeURL(url); | |
26 | - } | |
27 | -} | |
28 | ||
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; | |
33 | #endif | |
34 | ||
35 | +static char fWatchVariableForSyncInterface; | |
36 | +static char* fResultString; | |
37 | +static int fResultCode; | |
38 | + | |
39 | +static void responseHandlerForSyncInterface(RTSPClient* rtspClient, int responseCode, char* responseString) { | |
40 | + // Set result values: | |
41 | + fResultCode = responseCode; | |
42 | + fResultString = responseString; | |
43 | + | |
44 | + // Signal a break from the event loop (thereby returning from the blocking command): | |
45 | + fWatchVariableForSyncInterface = ~0; | |
46 | +} | |
47 | + | |
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; | |
54 | } | |
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", | |
59 | env->getResultMsg()); | |
60 | break; | |
61 | } | |
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; | |
68 | + else | |
69 | + delete[] fResultString; | |
70 | } else { // SIP | |
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) { | |
74 | ||
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; | |
84 | + | |
85 | if (!strcmp(subsession->mediumName(), "audio")) | |
86 | audiofound = 1; | |
87 | if (!strcmp(subsession->mediumName(), "video")) | |
88 | @@ -256,7 +268,11 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) { | |
89 | ||
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 | |
100 | } | |
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(); | |
110 | } |