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