4 #ifndef OWT_BASE_STREAM_H_ 5 #define OWT_BASE_STREAM_H_ 7 #include <unordered_map> 9 #include "owt/base/commontypes.h" 10 #include "owt/base/exception.h" 11 #include "owt/base/localcamerastreamparameters.h" 12 #include "owt/base/macros.h" 13 #include "owt/base/options.h" 14 #include "owt/base/videoencoderinterface.h" 15 #include "owt/base/videorendererinterface.h" 16 #include "owt/base/audioplayerinterface.h" 18 class MediaStreamInterface;
19 class VideoTrackSourceInterface;
20 class MediaConstraints;
23 namespace conference {
24 class ConferencePeerConnectionChannel;
25 class ConferenceClient;
29 class P2PPeerConnectionChannel;
32 class MediaConstraintsImpl;
33 class CustomizedFramesCapturer;
34 class BasicDesktopCapturer;
35 class VideoFrameGeneratorInterface;
36 #if defined(WEBRTC_MAC) 37 class ObjcVideoCapturerInterface;
39 using webrtc::MediaStreamInterface;
49 virtual void OnMute(TrackKind track_kind) {}
53 class WebrtcVideoRendererImpl;
54 class WebrtcAudioRendererImpl;
55 #if defined(WEBRTC_WIN) 56 class WebrtcVideoRendererD3D9Impl;
61 Stream(MediaStreamInterface* media_stream, StreamSourceInfo source);
63 MediaStreamInterface* MediaStream()
const;
69 virtual std::string
Id()
const;
83 virtual const std::unordered_map<std::string, std::string>
Attributes()
94 #if defined(WEBRTC_WIN) || defined(WEBRTC_LINUX) 116 Stream(
const std::string&
id);
119 void Id(
const std::string&
id);
120 void MediaStream(MediaStreamInterface* media_stream);
121 void TriggerOnStreamEnded();
122 void TriggerOnStreamUpdated();
123 void TriggerOnStreamMute(owt::base::TrackKind track_kind);
124 void TriggerOnStreamUnmute(owt::base::TrackKind track_kind);
125 MediaStreamInterface* media_stream_;
126 std::unordered_map<std::string, std::string> attributes_;
127 WebrtcVideoRendererImpl* renderer_impl_;
128 WebrtcAudioRendererImpl* audio_renderer_impl_;
129 #if defined(WEBRTC_WIN) 130 WebrtcVideoRendererD3D9Impl* d3d9_renderer_impl_;
135 void SetAudioTracksEnabled(
bool enabled);
136 void SetVideoTracksEnabled(
bool enabled);
139 mutable std::mutex observer_mutex_;
140 std::vector<std::reference_wrapper<StreamObserver>> observers_;
153 const std::unordered_map<int, std::string>& window_list,
163 #if !defined(WEBRTC_WIN) 175 const std::unordered_map<std::string, std::string>& attributes) {
176 attributes_ = attributes;
192 static std::shared_ptr<LocalStream>
Create(
204 static std::shared_ptr<LocalStream>
Create(
205 const bool is_audio_enabled,
206 webrtc::VideoTrackSourceInterface* video_source,
220 static std::shared_ptr<LocalStream>
Create(
221 std::shared_ptr<LocalCustomizedStreamParameters> parameters,
222 std::unique_ptr<VideoFrameGeneratorInterface> framer);
233 static std::shared_ptr<LocalStream>
Create(
234 std::shared_ptr<LocalCustomizedStreamParameters> parameters,
244 static std::shared_ptr<LocalStream>
Create(
245 std::shared_ptr<LocalDesktopStreamParameters> parameters,
246 std::unique_ptr<LocalScreenStreamObserver> observer);
252 webrtc::VideoTrackSourceInterface* video_source,
255 std::shared_ptr<LocalCustomizedStreamParameters> parameters,
256 std::unique_ptr<VideoFrameGeneratorInterface> framer);
258 std::shared_ptr<LocalCustomizedStreamParameters> parameters,
260 explicit LocalStream(std::shared_ptr<LocalDesktopStreamParameters> parameters,
261 std::unique_ptr<LocalScreenStreamObserver> observer);
264 bool encoded_ =
false;
265 #if defined(WEBRTC_MAC) 266 std::unique_ptr<ObjcVideoCapturerInterface> capturer_;
275 friend class owt::conference::ConferencePeerConnectionChannel;
278 friend class owt::p2p::P2PPeerConnectionChannel;
283 const std::string&
id,
284 const std::string& from,
287 explicit RemoteStream(MediaStreamInterface* media_stream,
288 const std::string& from);
290 const std::unordered_map<std::string, std::string>& attributes) {
291 attributes_ = attributes;
307 subscription_capabilities_ = subscription_capabilities;
310 void Settings(
const PublicationSettings& publication_settings) {
311 publication_settings_ = publication_settings;
317 MediaStreamInterface* MediaStream();
318 void MediaStream(MediaStreamInterface* media_stream);
322 bool has_audio_ =
true;
323 bool has_video_ =
true;
329 #endif // OWT_BASE_STREAM_H_ Video encoder interface.
Definition: videoencoderinterface.h:16
virtual void OnMute(TrackKind track_kind)
Triggered when the stream is muted.
Definition: stream.h:49
void RemoveObserver(StreamObserver &observer)
De-Register an observer on the stream.
Observer for Stream.
Definition: stream.h:41
Information about the conference.
Definition: conferenceclient.h:98
virtual void DisableAudio()
Disable all audio tracks of the stream.
virtual std::string Id() const
Get the ID of the stream.
An asynchronous class for app to communicate with a conference in MCU.
Definition: conferenceclient.h:212
virtual void DetachVideoRenderer()
Detach the stream from its renderer.
This class represents a remote stream.
Definition: stream.h:274
virtual StreamSourceInfo Source() const
Returns the audio/video source info of the stream.
virtual void Attributes(const std::unordered_map< std::string, std::string > &attributes)
Set a user-defined attribute map.
Definition: stream.h:174
virtual void AttachVideoRenderer(VideoRendererInterface &renderer)
virtual void OnUnmute(TrackKind track_kind)
Triggered when the stream is unmuted.
Definition: stream.h:51
void AddObserver(StreamObserver &observer)
Register an observer on the stream.
virtual void DisableVideo()
Disable all video tracks of the stream.
Definition: audioplayerinterface.h:8
SubscriptionCapabilities Capabilities()
Get the subscription capabilities on the stream.
Definition: stream.h:299
VideoRenderWindow wraps a native Window handle.
Definition: videorendererinterface.h:36
virtual const std::unordered_map< std::string, std::string > Attributes() const
Returns a user-defined attribute map.
Definition: stream.h:83
virtual void AttachAudioPlayer(AudioPlayerInterface &player)
Base class of all streams with media stream.
Definition: stream.h:59
virtual void OnCaptureSourceNeeded(const std::unordered_map< int, std::string > &window_list, int &dest_window)
Event callback for local screen stream to request for a source from application.
Definition: stream.h:152
virtual void EnableAudio()
Enable all audio tracks of the stream.
PublicationSettings Settings()
Get the publication settings of the stream.
Definition: stream.h:301
Stream source.
Definition: commontypes.h:157
This class contains parameters and methods that needed for creating a local camera stream...
Definition: localcamerastreamparameters.h:17
void Close()
Close a local stream.
virtual void OnUpdated()
Triggered when the stream info is updated in conference mode.
Definition: stream.h:47
void Stop()
Stop the remote stream.
Definition: stream.h:314
This class represents a local stream.
Definition: stream.h:161
static std::shared_ptr< LocalStream > Create(const LocalCameraStreamParameters ¶meters, int &error_code)
Create a local camera stream. This creates a local camera stream with specified device settings...
virtual void DetachAudioPlayer()
Detach the stream from the audio player.
virtual void OnEnded()
Definition: stream.h:45
Interface for rendering VideoFrames in ARGB/I420 format from a VideoTrack.
Definition: videorendererinterface.h:74
virtual void EnableVideo()
Enable all video tracks of the stream.
Interface for rendering PCM data in a stream.
Definition: audioplayerinterface.h:11