0002-mpdemux-live555-async-interface.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. From d3195ea13f4a9aae546ff996e53681349a1a3cdb Mon Sep 17 00:00:00 2001
  2. From: sherpya <sherpya@netfarm.it>
  3. Date: Fri, 14 Jun 2013 05:25:38 +0200
  4. Subject: [PATCH 25/27] mpdemux: live555 async interface
  5. From: https://raw.github.com/sherpya/mplayer-be/master/patches/mp/0025-mpdemux-live555-async-interface.patch
  6. Adjust live555 interface code for modern versions of live555.
  7. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  8. ---
  9. libmpdemux/demux_rtp.cpp | 51 ++++++++++++++++++++++++++++++++----------------
  10. 2 files changed, 35 insertions(+), 22 deletions(-)
  11. diff --git a/libmpdemux/demux_rtp.cpp b/libmpdemux/demux_rtp.cpp
  12. index ad7a7f1..05d06e0 100644
  13. --- a/libmpdemux/demux_rtp.cpp
  14. +++ b/libmpdemux/demux_rtp.cpp
  15. @@ -19,8 +19,6 @@
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. -#define RTSPCLIENT_SYNCHRONOUS_INTERFACE 1
  19. -
  20. extern "C" {
  21. // on MinGW, we must include windows.h before the things it conflicts
  22. #ifdef __MINGW32__ // with. they are each protected from
  23. @@ -94,15 +92,6 @@ struct RTPState {
  24. extern "C" char* network_username;
  25. extern "C" char* network_password;
  26. -static char* openURL_rtsp(RTSPClient* client, char const* url) {
  27. - // If we were given a user name (and optional password), then use them:
  28. - if (network_username != NULL) {
  29. - char const* password = network_password == NULL ? "" : network_password;
  30. - return client->describeWithPassword(url, network_username, password);
  31. - } else {
  32. - return client->describeURL(url);
  33. - }
  34. -}
  35. static char* openURL_sip(SIPClient* client, char const* url) {
  36. // If we were given a user name (and optional password), then use them:
  37. @@ -118,6 +107,19 @@ static char* openURL_sip(SIPClient* client, char const* url) {
  38. extern AVCodecContext *avcctx;
  39. #endif
  40. +static char fWatchVariableForSyncInterface;
  41. +static char* fResultString;
  42. +static int fResultCode;
  43. +
  44. +static void responseHandlerForSyncInterface(RTSPClient* rtspClient, int responseCode, char* responseString) {
  45. + // Set result values:
  46. + fResultCode = responseCode;
  47. + fResultString = responseString;
  48. +
  49. + // Signal a break from the event loop (thereby returning from the blocking command):
  50. + fWatchVariableForSyncInterface = ~0;
  51. +}
  52. +
  53. extern "C" int audio_id, video_id, dvdsub_id;
  54. extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
  55. Boolean success = False;
  56. @@ -146,13 +148,19 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
  57. rtsp_transport_http = demuxer->stream->streaming_ctrl->url->port;
  58. rtsp_transport_tcp = 1;
  59. }
  60. - rtspClient = RTSPClient::createNew(*env, verbose, "MPlayer", rtsp_transport_http);
  61. + rtspClient = RTSPClient::createNew(*env, url, verbose, "MPlayer", rtsp_transport_http);
  62. if (rtspClient == NULL) {
  63. fprintf(stderr, "Failed to create RTSP client: %s\n",
  64. env->getResultMsg());
  65. break;
  66. }
  67. - sdpDescription = openURL_rtsp(rtspClient, url);
  68. + fWatchVariableForSyncInterface = 0;
  69. + rtspClient->sendDescribeCommand(responseHandlerForSyncInterface);
  70. + env->taskScheduler().doEventLoop(&fWatchVariableForSyncInterface);
  71. + if (fResultCode == 0)
  72. + sdpDescription = fResultString;
  73. + else
  74. + delete[] fResultString;
  75. } else { // SIP
  76. unsigned char desiredAudioType = 0; // PCMU (use 3 for GSM)
  77. sipClient = SIPClient::createNew(*env, desiredAudioType, NULL,
  78. @@ -236,8 +244,12 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
  79. if (rtspClient != NULL) {
  80. // Issue a RTSP "SETUP" command on the chosen subsession:
  81. - if (!rtspClient->setupMediaSubsession(*subsession, False,
  82. - rtsp_transport_tcp)) break;
  83. + fWatchVariableForSyncInterface = 0;
  84. + rtspClient->sendSetupCommand(*subsession, responseHandlerForSyncInterface, False, rtsp_transport_tcp);
  85. + env->taskScheduler().doEventLoop(&fWatchVariableForSyncInterface);
  86. + delete[] fResultString;
  87. + if (fResultCode != 0) break;
  88. +
  89. if (!strcmp(subsession->mediumName(), "audio"))
  90. audiofound = 1;
  91. if (!strcmp(subsession->mediumName(), "video"))
  92. @@ -248,7 +260,11 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
  93. if (rtspClient != NULL) {
  94. // Issue a RTSP aggregate "PLAY" command on the whole session:
  95. - if (!rtspClient->playMediaSession(*mediaSession)) break;
  96. + fWatchVariableForSyncInterface = 0;
  97. + rtspClient->sendPlayCommand(*mediaSession, responseHandlerForSyncInterface);
  98. + env->taskScheduler().doEventLoop(&fWatchVariableForSyncInterface);
  99. + delete[] fResultString;
  100. + if (fResultCode != 0) break;
  101. } else if (sipClient != NULL) {
  102. sipClient->sendACK(); // to start the stream flowing
  103. }
  104. @@ -637,7 +653,8 @@ static void teardownRTSPorSIPSession(RTPState* rtpState) {
  105. MediaSession* mediaSession = rtpState->mediaSession;
  106. if (mediaSession == NULL) return;
  107. if (rtpState->rtspClient != NULL) {
  108. - rtpState->rtspClient->teardownMediaSession(*mediaSession);
  109. + fWatchVariableForSyncInterface = 0;
  110. + rtpState->rtspClient->sendTeardownCommand(*mediaSession, NULL);
  111. } else if (rtpState->sipClient != NULL) {
  112. rtpState->sipClient->sendBYE();
  113. }
  114. --
  115. 1.8.5.2