3
* Copyright 2011, Google Inc.
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
* 3. The name of the author may not be used to endorse or promote products
14
* derived from this software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
// This file contains interfaces for MediaStream and MediaTrack. These
29
// interfaces are used for implementing MediaStream and MediaTrack as defined
30
// in http://dev.w3.org/2011/webrtc/editor/webrtc.html#stream-api. These
31
// interfaces must be used only with PeerConnection. PeerConnectionManager
32
// interface provides the factory methods to create MediaStream and MediaTracks.
34
#ifndef TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_
35
#define TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_
39
#include "talk/base/basictypes.h"
40
#include "talk/base/refcount.h"
41
#include "talk/base/scoped_ref_ptr.h"
49
} // namespace cricket
53
class AudioDeviceModule;
55
// Generic observer interface.
56
class ObserverInterface {
58
virtual void OnChanged() = 0;
61
virtual ~ObserverInterface() {}
64
class NotifierInterface {
66
virtual void RegisterObserver(ObserverInterface* observer) = 0;
67
virtual void UnregisterObserver(ObserverInterface* observer) = 0;
69
virtual ~NotifierInterface() {}
72
// Information about a track.
73
class MediaStreamTrackInterface : public talk_base::RefCountInterface,
74
public NotifierInterface {
77
kInitializing, // Track is beeing negotiated.
78
kLive = 1, // Track alive
79
kEnded = 2, // Track have ended
80
kFailed = 3, // Track negotiation failed.
83
virtual std::string kind() const = 0;
84
virtual std::string label() const = 0;
85
virtual bool enabled() const = 0;
86
virtual TrackState state() const = 0;
87
virtual bool set_enabled(bool enable) = 0;
88
// These methods should be called by implementation only.
89
virtual bool set_state(TrackState new_state) = 0;
92
// Reference counted wrapper for a VideoRenderer.
93
class VideoRendererWrapperInterface : public talk_base::RefCountInterface {
95
virtual cricket::VideoRenderer* renderer() = 0;
98
virtual ~VideoRendererWrapperInterface() {}
101
// Creates a reference counted object of type cricket::VideoRenderer.
102
// webrtc::VideoRendererWrapperInterface take ownership of
103
// cricket::VideoRenderer.
104
talk_base::scoped_refptr<VideoRendererWrapperInterface> CreateVideoRenderer(
105
cricket::VideoRenderer* renderer);
107
class VideoTrackInterface : public MediaStreamTrackInterface {
109
// Set the video renderer for a local or remote stream.
110
// This call will start decoding the received video stream and render it.
111
// The VideoRendererInterface is stored as a scoped_refptr. This means that
112
// it is not allowed to call delete renderer after this API has been called.
113
virtual void SetRenderer(VideoRendererWrapperInterface* renderer) = 0;
115
// Get the VideoRenderer associated with this track.
116
virtual VideoRendererWrapperInterface* GetRenderer() = 0;
119
virtual ~VideoTrackInterface() {}
122
class LocalVideoTrackInterface : public VideoTrackInterface {
124
// Get the VideoCapturer associated with the track.
125
virtual cricket::VideoCapturer* GetVideoCapture() = 0;
128
virtual ~LocalVideoTrackInterface() {}
131
class AudioTrackInterface : public MediaStreamTrackInterface {
134
virtual ~AudioTrackInterface() {}
137
class LocalAudioTrackInterface : public AudioTrackInterface {
139
// Get the AudioDeviceModule associated with this track.
140
virtual AudioDeviceModule* GetAudioDevice() = 0;
142
virtual ~LocalAudioTrackInterface() {}
145
// List of of tracks.
146
template <class TrackType>
147
class MediaStreamTrackListInterface : public talk_base::RefCountInterface {
149
virtual size_t count() const = 0;
150
virtual TrackType* at(size_t index) = 0;
153
virtual ~MediaStreamTrackListInterface() {}
156
typedef MediaStreamTrackListInterface<AudioTrackInterface> AudioTracks;
157
typedef MediaStreamTrackListInterface<VideoTrackInterface> VideoTracks;
159
class MediaStreamInterface : public talk_base::RefCountInterface,
160
public NotifierInterface {
162
virtual std::string label() const = 0;
163
virtual AudioTracks* audio_tracks() = 0;
164
virtual VideoTracks* video_tracks() = 0;
168
kLive = 1, // Stream alive
169
kEnded = 2, // Stream have ended
172
virtual ReadyState ready_state() const = 0;
174
// These methods should be called by implementation only.
175
virtual void set_ready_state(ReadyState state) = 0;
178
virtual ~MediaStreamInterface() {}
181
class LocalMediaStreamInterface : public MediaStreamInterface {
183
virtual bool AddTrack(AudioTrackInterface* track) = 0;
184
virtual bool AddTrack(VideoTrackInterface* track) = 0;
187
} // namespace webrtc
189
#endif // TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_