Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 | 33 |
| 34 #ifndef TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ | 34 #ifndef TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ |
| 35 #define TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ | 35 #define TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ |
| 36 | 36 |
| 37 #include <string> | 37 #include <string> |
| 38 #include <vector> | 38 #include <vector> |
| 39 | 39 |
| 40 #include "webrtc/base/basictypes.h" | 40 #include "webrtc/base/basictypes.h" |
| 41 #include "webrtc/base/refcount.h" | 41 #include "webrtc/base/refcount.h" |
| 42 #include "webrtc/base/scoped_ref_ptr.h" | 42 #include "webrtc/base/scoped_ref_ptr.h" |
| 43 #include "webrtc/media/base/videosinkinterface.h" | |
| 43 | 44 |
| 44 namespace cricket { | 45 namespace cricket { |
| 45 | 46 |
| 46 class AudioRenderer; | 47 class AudioRenderer; |
| 47 class VideoCapturer; | 48 class VideoCapturer; |
| 48 class VideoRenderer; | 49 class VideoRenderer; |
| 49 class VideoFrame; | 50 class VideoFrame; |
| 50 | 51 |
| 51 } // namespace cricket | 52 } // namespace cricket |
| 52 | 53 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 virtual TrackState state() const = 0; | 110 virtual TrackState state() const = 0; |
| 110 virtual bool set_enabled(bool enable) = 0; | 111 virtual bool set_enabled(bool enable) = 0; |
| 111 // These methods should be called by implementation only. | 112 // These methods should be called by implementation only. |
| 112 virtual bool set_state(TrackState new_state) = 0; | 113 virtual bool set_state(TrackState new_state) = 0; |
| 113 | 114 |
| 114 protected: | 115 protected: |
| 115 virtual ~MediaStreamTrackInterface() {} | 116 virtual ~MediaStreamTrackInterface() {} |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 // Interface for rendering VideoFrames from a VideoTrack | 119 // Interface for rendering VideoFrames from a VideoTrack |
| 119 class VideoRendererInterface { | 120 class VideoRendererInterface |
| 121 : public rtc::VideoSinkInterface<cricket::VideoFrame> { | |
| 120 public: | 122 public: |
| 121 // |frame| may have pending rotation. For clients which can't apply rotation, | 123 // |frame| may have pending rotation. For clients which can't apply rotation, |
| 122 // |frame|->GetCopyWithRotationApplied() will return a frame that has the | 124 // |frame|->GetCopyWithRotationApplied() will return a frame that has the |
| 123 // rotation applied. | 125 // rotation applied. |
| 124 virtual void RenderFrame(const cricket::VideoFrame* frame) = 0; | 126 virtual void RenderFrame(const cricket::VideoFrame* frame) = 0; |
| 127 // Intended to replace RenderFrame. | |
| 128 void OnFrame(const cricket::VideoFrame& frame) override { | |
| 129 RenderFrame(&frame); | |
| 130 } | |
| 125 | 131 |
| 126 protected: | 132 protected: |
| 127 // The destructor is protected to prevent deletion via the interface. | 133 // The destructor is protected to prevent deletion via the interface. |
| 128 // This is so that we allow reference counted classes, where the destructor | 134 // This is so that we allow reference counted classes, where the destructor |
| 129 // should never be public, to implement the interface. | 135 // should never be public, to implement the interface. |
| 130 virtual ~VideoRendererInterface() {} | 136 virtual ~VideoRendererInterface() {} |
| 131 }; | 137 }; |
| 132 | 138 |
| 133 class VideoSourceInterface; | 139 class VideoSourceInterface; |
| 134 | 140 |
| 135 class VideoTrackInterface : public MediaStreamTrackInterface { | 141 class VideoTrackInterface : public MediaStreamTrackInterface { |
| 136 public: | 142 public: |
| 137 // Register a renderer that will render all frames received on this track. | 143 // Backwards compatibility wrappers |
| 138 virtual void AddRenderer(VideoRendererInterface* renderer) = 0; | 144 virtual void AddRenderer(VideoRendererInterface* renderer) { |
| 139 // Deregister a renderer. | 145 AddSink(renderer); |
| 140 virtual void RemoveRenderer(VideoRendererInterface* renderer) = 0; | 146 } |
| 141 | 147 virtual void RemoveRenderer(VideoRendererInterface* renderer) { |
| 148 RemoveSink(renderer); | |
| 149 } | |
| 150 // Register a sink that will receive all frames received on this | |
| 151 // track. Tolerates sink == nullptr, and does nothing. | |
|
perkj_webrtc
2016/01/28 13:45:16
I think we should try to be strict. Prefer to not
nisse-webrtc
2016/01/29 07:48:29
Added a RTC_DCHECK in AddSink, and hopefully made
| |
| 152 virtual void AddSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) = 0; | |
| 153 // Deregister a sink. Tolerates sink == nullptr. | |
| 154 virtual void RemoveSink( | |
| 155 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) = 0; | |
| 142 virtual VideoSourceInterface* GetSource() const = 0; | 156 virtual VideoSourceInterface* GetSource() const = 0; |
| 143 | 157 |
| 144 protected: | 158 protected: |
| 145 virtual ~VideoTrackInterface() {} | 159 virtual ~VideoTrackInterface() {} |
| 146 }; | 160 }; |
| 147 | 161 |
| 148 // Interface for receiving audio data from a AudioTrack. | 162 // Interface for receiving audio data from a AudioTrack. |
| 149 class AudioTrackSinkInterface { | 163 class AudioTrackSinkInterface { |
| 150 public: | 164 public: |
| 151 virtual void OnData(const void* audio_data, | 165 virtual void OnData(const void* audio_data, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; | 281 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; |
| 268 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; | 282 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; |
| 269 | 283 |
| 270 protected: | 284 protected: |
| 271 virtual ~MediaStreamInterface() {} | 285 virtual ~MediaStreamInterface() {} |
| 272 }; | 286 }; |
| 273 | 287 |
| 274 } // namespace webrtc | 288 } // namespace webrtc |
| 275 | 289 |
| 276 #endif // TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ | 290 #endif // TALK_APP_WEBRTC_MEDIASTREAMINTERFACE_H_ |
| OLD | NEW |