~ubuntu-branches/debian/experimental/kopete/experimental

« back to all changes in this revision

Viewing changes to protocols/jabber/googletalk/libjingle/talk/app/webrtc/mediastreaminterface.h

  • Committer: Package Import Robot
  • Author(s): Maximiliano Curia
  • Date: 2015-02-24 11:32:57 UTC
  • mfrom: (1.1.41 vivid)
  • Revision ID: package-import@ubuntu.com-20150224113257-gnupg4v7lzz18ij0
Tags: 4:14.12.2-1
* New upstream release (14.12.2).
* Bump Standards-Version to 3.9.6, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libjingle
3
 
 * Copyright 2011, Google Inc.
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions are met:
7
 
 *
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.
15
 
 *
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.
26
 
 */
27
 
 
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.
33
 
 
34
 
#ifndef TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_
35
 
#define TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_
36
 
 
37
 
#include <string>
38
 
 
39
 
#include "talk/base/basictypes.h"
40
 
#include "talk/base/refcount.h"
41
 
#include "talk/base/scoped_ref_ptr.h"
42
 
 
43
 
namespace cricket {
44
 
 
45
 
class VideoCapturer;
46
 
class VideoRenderer;
47
 
class MediaEngine;
48
 
 
49
 
}  // namespace cricket
50
 
 
51
 
namespace webrtc {
52
 
 
53
 
class AudioDeviceModule;
54
 
 
55
 
// Generic observer interface.
56
 
class ObserverInterface {
57
 
 public:
58
 
  virtual void OnChanged() = 0;
59
 
 
60
 
 protected:
61
 
  virtual ~ObserverInterface() {}
62
 
};
63
 
 
64
 
class NotifierInterface {
65
 
 public:
66
 
  virtual void RegisterObserver(ObserverInterface* observer) = 0;
67
 
  virtual void UnregisterObserver(ObserverInterface* observer) = 0;
68
 
 
69
 
  virtual ~NotifierInterface() {}
70
 
};
71
 
 
72
 
// Information about a track.
73
 
class MediaStreamTrackInterface : public talk_base::RefCountInterface,
74
 
                                  public NotifierInterface {
75
 
 public:
76
 
  enum TrackState {
77
 
    kInitializing,  // Track is beeing negotiated.
78
 
    kLive = 1,  // Track alive
79
 
    kEnded = 2,  // Track have ended
80
 
    kFailed = 3,  // Track negotiation failed.
81
 
  };
82
 
 
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;
90
 
};
91
 
 
92
 
// Reference counted wrapper for a VideoRenderer.
93
 
class VideoRendererWrapperInterface : public talk_base::RefCountInterface {
94
 
 public:
95
 
  virtual cricket::VideoRenderer* renderer() = 0;
96
 
 
97
 
 protected:
98
 
  virtual ~VideoRendererWrapperInterface() {}
99
 
};
100
 
 
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);
106
 
 
107
 
class VideoTrackInterface : public MediaStreamTrackInterface {
108
 
 public:
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;
114
 
 
115
 
  // Get the VideoRenderer associated with this track.
116
 
  virtual VideoRendererWrapperInterface* GetRenderer() = 0;
117
 
 
118
 
 protected:
119
 
  virtual ~VideoTrackInterface() {}
120
 
};
121
 
 
122
 
class LocalVideoTrackInterface : public VideoTrackInterface {
123
 
 public:
124
 
  // Get the VideoCapturer associated with the track.
125
 
  virtual cricket::VideoCapturer* GetVideoCapture() = 0;
126
 
 
127
 
 protected:
128
 
  virtual ~LocalVideoTrackInterface() {}
129
 
};
130
 
 
131
 
class AudioTrackInterface : public MediaStreamTrackInterface {
132
 
 public:
133
 
 protected:
134
 
  virtual ~AudioTrackInterface() {}
135
 
};
136
 
 
137
 
class LocalAudioTrackInterface : public AudioTrackInterface {
138
 
 public:
139
 
  // Get the AudioDeviceModule associated with this track.
140
 
  virtual AudioDeviceModule* GetAudioDevice() =  0;
141
 
 protected:
142
 
  virtual ~LocalAudioTrackInterface() {}
143
 
};
144
 
 
145
 
// List of of tracks.
146
 
template <class TrackType>
147
 
class MediaStreamTrackListInterface : public talk_base::RefCountInterface {
148
 
 public:
149
 
  virtual size_t count() const = 0;
150
 
  virtual TrackType* at(size_t index) = 0;
151
 
 
152
 
 protected:
153
 
  virtual ~MediaStreamTrackListInterface() {}
154
 
};
155
 
 
156
 
typedef MediaStreamTrackListInterface<AudioTrackInterface> AudioTracks;
157
 
typedef MediaStreamTrackListInterface<VideoTrackInterface> VideoTracks;
158
 
 
159
 
class MediaStreamInterface : public talk_base::RefCountInterface,
160
 
                             public NotifierInterface {
161
 
 public:
162
 
  virtual std::string label() const = 0;
163
 
  virtual AudioTracks* audio_tracks() = 0;
164
 
  virtual VideoTracks* video_tracks() = 0;
165
 
 
166
 
  enum ReadyState {
167
 
    kInitializing,
168
 
    kLive = 1,  // Stream alive
169
 
    kEnded = 2,  // Stream have ended
170
 
  };
171
 
 
172
 
  virtual ReadyState ready_state() const = 0;
173
 
 
174
 
  // These methods should be called by implementation only.
175
 
  virtual void set_ready_state(ReadyState state) = 0;
176
 
 
177
 
 protected:
178
 
  virtual ~MediaStreamInterface() {}
179
 
};
180
 
 
181
 
class LocalMediaStreamInterface : public MediaStreamInterface {
182
 
 public:
183
 
  virtual bool AddTrack(AudioTrackInterface* track) = 0;
184
 
  virtual bool AddTrack(VideoTrackInterface* track) = 0;
185
 
};
186
 
 
187
 
}  // namespace webrtc
188
 
 
189
 
#endif  // TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_