summaryrefslogtreecommitdiffstats
path: root/netwerk/base/nsIStreamingProtocolController.idl
blob: 249e8e983059495015e18a0e54375b487f9ab429 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=4 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface nsIURI;

#include "nsISupports.idl"

%{C++
#define MEDIASTREAM_FRAMETYPE_NORMAL          0x00000001
#define MEDIASTREAM_FRAMETYPE_DISCONTINUITY   0x00000002
#define MEDIASTREAM_FRAMETYPE_END_OF_STREAM   0x00000004
%}

/**
 * Metadata of the media stream.
 */
[uuid(294adb30-856c-11e2-9e96-0800200c9a66)]
interface nsIStreamingProtocolMetaData : nsISupports
{
    /**
     * Frame type.
     */
    attribute uint32_t frameType;

    /**
     * The total tracks for the given media stream session.
     */
    attribute uint32_t totalTracks;

    /**
     * The mime type of the track.
     */
    attribute ACString mimeType;

    /**
     * The width of the resolution.
     */
    attribute unsigned long width;

    /**
     * The height of the resolution.
     */
    attribute unsigned long height;

    /**
     * The duration of the media stream in units of microseconds.
     */
    attribute unsigned long long duration;

    /**
     * The sample rate of the media stream.
     */
    attribute unsigned long sampleRate;

    /**
     * The timestamp indicates the stream absolute position
     * relative to the beginning of the presentation.
     */
    attribute unsigned long long timeStamp;

    /**
     * The total number of audio channels in the media stream.
     */
    attribute unsigned long channelCount;

    /**
     * The AAC audio codec specific data.
     */
    attribute ACString esdsData;

    /**
     * The AVCC format extradata of H.264 stream.
     */
    attribute ACString avccData;
};

/**
 * nsIStreamingProtocolListener
 */
[scriptable, uuid(c4f6b660-892e-11e2-9e96-0800200c9a66)]
interface nsIStreamingProtocolListener : nsISupports
{
    /**
     * Called when the data may be read without blocking the calling thread.
     * @param index The track number of the media stream.
     * @param data Raw data of the media stream on given track number.
     * @param length The length of the raw data.
     * @param offset The offset in the data stream from the start of the media
     *               presentation in bytes.
     * @param meta The meta data of the frame.
     */
    void onMediaDataAvailable(in uint8_t index,
                              in ACString data,
                              in uint32_t length,
                              in uint32_t offset,
                              in nsIStreamingProtocolMetaData meta);

    /**
     * Called when the meta data for a given session is available.
     * @param index The track number of the media stream.
     * @param meta The meta data of the media stream.
     */
    void onConnected(in uint8_t index, in nsIStreamingProtocolMetaData meta);

    /**
     * Called when the Rtsp session is closed.
     * @param index Track number of the media stream.
     * @param reason The reason of disconnection.
     */
    void onDisconnected(in uint8_t index, in nsresult reason);
};

/**
 * Media stream controller API: control and retrieve meta data from media stream.
 */
[uuid(4ce040f0-c50d-461f-94e2-af5a77fe13a5)]
interface nsIStreamingProtocolController : nsISupports
{
    /**
     * Preprare the URI before we can start the connection.
     * @param aUri The URI of the media stream.
     */
    void init(in nsIURI aUri);

    /**
     * Asynchronously open this controller.  Data is fed to the specified
     * media stream listener as it becomes available. If asyncOpen returns
     * successfully, the controller is responsible for keeping itself alive
     * until it has called onStopRequest on aListener.
     *
     * @param aListener The nsIStreamingProtocolListener implementation
     */
    void asyncOpen(in nsIStreamingProtocolListener aListener);

    /*
     * Get the metadata of a track.
     * @param index Index of a track.
     * @return A nsIStreamingProtocolMetaData.
     */
    nsIStreamingProtocolMetaData getTrackMetaData(in octet index);

    /*
     * Tell the streaming server to start sending media data.
     */
    void play();

    /*
     * Tell the streaming server to pause sending media data.
     */
    void pause();

    /*
     * Tell the streaming server to resume the suspended media stream.
     */
    void resume();

    /*
     * Tell the streaming server to suspend the media stream.
     */
    void suspend();

    /*
     * Tell the streaming server to send media data in specific time.
     * @param seekTimeUs Start time of the media stream in microseconds.
     */
    void seek(in unsigned long long seekTimeUs);

    /*
     * Tell the streaming server to stop the
     * media stream and close the connection.
     */
    void stop();

    /*
     * Notify the streaming controller that the playback has ended.
     * The controller might have to perform certain internal state transition.
     */
    void playbackEnded();

    /**
     * Total number of audio/video tracks.
     */
    readonly attribute octet totalTracks;
};