nsIStreamingProtocolController.idl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. interface nsIURI;
  6. #include "nsISupports.idl"
  7. %{C++
  8. #define MEDIASTREAM_FRAMETYPE_NORMAL 0x00000001
  9. #define MEDIASTREAM_FRAMETYPE_DISCONTINUITY 0x00000002
  10. #define MEDIASTREAM_FRAMETYPE_END_OF_STREAM 0x00000004
  11. %}
  12. /**
  13. * Metadata of the media stream.
  14. */
  15. [uuid(294adb30-856c-11e2-9e96-0800200c9a66)]
  16. interface nsIStreamingProtocolMetaData : nsISupports
  17. {
  18. /**
  19. * Frame type.
  20. */
  21. attribute uint32_t frameType;
  22. /**
  23. * The total tracks for the given media stream session.
  24. */
  25. attribute uint32_t totalTracks;
  26. /**
  27. * The mime type of the track.
  28. */
  29. attribute ACString mimeType;
  30. /**
  31. * The width of the resolution.
  32. */
  33. attribute unsigned long width;
  34. /**
  35. * The height of the resolution.
  36. */
  37. attribute unsigned long height;
  38. /**
  39. * The duration of the media stream in units of microseconds.
  40. */
  41. attribute unsigned long long duration;
  42. /**
  43. * The sample rate of the media stream.
  44. */
  45. attribute unsigned long sampleRate;
  46. /**
  47. * The timestamp indicates the stream absolute position
  48. * relative to the beginning of the presentation.
  49. */
  50. attribute unsigned long long timeStamp;
  51. /**
  52. * The total number of audio channels in the media stream.
  53. */
  54. attribute unsigned long channelCount;
  55. /**
  56. * The AAC audio codec specific data.
  57. */
  58. attribute ACString esdsData;
  59. /**
  60. * The AVCC format extradata of H.264 stream.
  61. */
  62. attribute ACString avccData;
  63. };
  64. /**
  65. * nsIStreamingProtocolListener
  66. */
  67. [scriptable, uuid(c4f6b660-892e-11e2-9e96-0800200c9a66)]
  68. interface nsIStreamingProtocolListener : nsISupports
  69. {
  70. /**
  71. * Called when the data may be read without blocking the calling thread.
  72. * @param index The track number of the media stream.
  73. * @param data Raw data of the media stream on given track number.
  74. * @param length The length of the raw data.
  75. * @param offset The offset in the data stream from the start of the media
  76. * presentation in bytes.
  77. * @param meta The meta data of the frame.
  78. */
  79. void onMediaDataAvailable(in uint8_t index,
  80. in ACString data,
  81. in uint32_t length,
  82. in uint32_t offset,
  83. in nsIStreamingProtocolMetaData meta);
  84. /**
  85. * Called when the meta data for a given session is available.
  86. * @param index The track number of the media stream.
  87. * @param meta The meta data of the media stream.
  88. */
  89. void onConnected(in uint8_t index, in nsIStreamingProtocolMetaData meta);
  90. /**
  91. * Called when the Rtsp session is closed.
  92. * @param index Track number of the media stream.
  93. * @param reason The reason of disconnection.
  94. */
  95. void onDisconnected(in uint8_t index, in nsresult reason);
  96. };
  97. /**
  98. * Media stream controller API: control and retrieve meta data from media stream.
  99. */
  100. [uuid(4ce040f0-c50d-461f-94e2-af5a77fe13a5)]
  101. interface nsIStreamingProtocolController : nsISupports
  102. {
  103. /**
  104. * Preprare the URI before we can start the connection.
  105. * @param aUri The URI of the media stream.
  106. */
  107. void init(in nsIURI aUri);
  108. /**
  109. * Asynchronously open this controller. Data is fed to the specified
  110. * media stream listener as it becomes available. If asyncOpen returns
  111. * successfully, the controller is responsible for keeping itself alive
  112. * until it has called onStopRequest on aListener.
  113. *
  114. * @param aListener The nsIStreamingProtocolListener implementation
  115. */
  116. void asyncOpen(in nsIStreamingProtocolListener aListener);
  117. /*
  118. * Get the metadata of a track.
  119. * @param index Index of a track.
  120. * @return A nsIStreamingProtocolMetaData.
  121. */
  122. nsIStreamingProtocolMetaData getTrackMetaData(in octet index);
  123. /*
  124. * Tell the streaming server to start sending media data.
  125. */
  126. void play();
  127. /*
  128. * Tell the streaming server to pause sending media data.
  129. */
  130. void pause();
  131. /*
  132. * Tell the streaming server to resume the suspended media stream.
  133. */
  134. void resume();
  135. /*
  136. * Tell the streaming server to suspend the media stream.
  137. */
  138. void suspend();
  139. /*
  140. * Tell the streaming server to send media data in specific time.
  141. * @param seekTimeUs Start time of the media stream in microseconds.
  142. */
  143. void seek(in unsigned long long seekTimeUs);
  144. /*
  145. * Tell the streaming server to stop the
  146. * media stream and close the connection.
  147. */
  148. void stop();
  149. /*
  150. * Notify the streaming controller that the playback has ended.
  151. * The controller might have to perform certain internal state transition.
  152. */
  153. void playbackEnded();
  154. /**
  155. * Total number of audio/video tracks.
  156. */
  157. readonly attribute octet totalTracks;
  158. };