| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_LOCAL_VIDEO_RENDERER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_RENDERER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_LOCAL_VIDEO_RENDERER_H_ | 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/renderer/media_stream_video_sink.h" |
| 10 #include "content/renderer/media/video_frame_provider.h" | 11 #include "content/renderer/media/video_frame_provider.h" |
| 11 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 12 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 12 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class MessageLoopProxy; | 16 class MessageLoopProxy; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 // RTCVideoRenderer is a VideoFrameProvider designed for rendering | 21 // RTCVideoRenderer is a VideoFrameProvider designed for rendering |
| 21 // Video MediaStreamTracks, | 22 // Video MediaStreamTracks, |
| 22 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamtrack | 23 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamtrack |
| 23 // RTCVideoRenderer implements webrtc::VideoRendererInterface in order to render | 24 // RTCVideoRenderer implements VideoTrackSink in order to render |
| 24 // video frames provided from a webrtc::VideoTrackInteface. | 25 // video frames provided from a VideoTrack. |
| 25 // RTCVideoRenderer register itself to the Video Track when the | 26 // RTCVideoRenderer register itself as a sink to the VideoTrack when the |
| 26 // VideoFrameProvider is started and deregisters itself when it is stopped. | 27 // VideoFrameProvider is started and deregisters itself when it is stopped. |
| 27 // Calls to webrtc::VideoTrackInterface must occur on the main thread. | |
| 28 // TODO(wuchengli): Add unit test. See the link below for reference. | 28 // TODO(wuchengli): Add unit test. See the link below for reference. |
| 29 // http://src.chromium.org/viewvc/chrome/trunk/src/content/renderer/media/rtc_vi | 29 // http://src.chromium.org/viewvc/chrome/trunk/src/content/renderer/media/rtc_vi |
| 30 // deo_decoder_unittest.cc?revision=180591&view=markup | 30 // deo_decoder_unittest.cc?revision=180591&view=markup |
| 31 class CONTENT_EXPORT RTCVideoRenderer | 31 class CONTENT_EXPORT RTCVideoRenderer |
| 32 : NON_EXPORTED_BASE(public VideoFrameProvider), | 32 : NON_EXPORTED_BASE(public VideoFrameProvider), |
| 33 NON_EXPORTED_BASE(public webrtc::VideoRendererInterface), | 33 NON_EXPORTED_BASE(public MediaStreamVideoSink) { |
| 34 NON_EXPORTED_BASE(public webrtc::ObserverInterface) { | |
| 35 public: | 34 public: |
| 36 RTCVideoRenderer( | 35 RTCVideoRenderer(const blink::WebMediaStreamTrack& video_track, |
| 37 webrtc::VideoTrackInterface* video_track, | 36 const base::Closure& error_cb, |
| 38 const base::Closure& error_cb, | 37 const RepaintCB& repaint_cb); |
| 39 const RepaintCB& repaint_cb); | |
| 40 | 38 |
| 41 // VideoFrameProvider implementation. Called on the main thread. | 39 // VideoFrameProvider implementation. Called on the main thread. |
| 42 virtual void Start() OVERRIDE; | 40 virtual void Start() OVERRIDE; |
| 43 virtual void Stop() OVERRIDE; | 41 virtual void Stop() OVERRIDE; |
| 44 virtual void Play() OVERRIDE; | 42 virtual void Play() OVERRIDE; |
| 45 virtual void Pause() OVERRIDE; | 43 virtual void Pause() OVERRIDE; |
| 46 | 44 |
| 47 // webrtc::VideoRendererInterface implementation. May be called on | |
| 48 // a different thread. | |
| 49 virtual void SetSize(int width, int height) OVERRIDE; | |
| 50 virtual void RenderFrame(const cricket::VideoFrame* frame) OVERRIDE; | |
| 51 | |
| 52 // webrtc::ObserverInterface implementation. | |
| 53 virtual void OnChanged() OVERRIDE; | |
| 54 | |
| 55 protected: | 45 protected: |
| 56 virtual ~RTCVideoRenderer(); | 46 virtual ~RTCVideoRenderer(); |
| 57 | 47 |
| 58 private: | 48 private: |
| 59 enum State { | 49 enum State { |
| 60 kStarted, | 50 kStarted, |
| 61 kPaused, | 51 kPaused, |
| 62 kStopped, | 52 kStopped, |
| 63 }; | 53 }; |
| 64 | 54 |
| 65 void MaybeRenderSignalingFrame(); | 55 // VideoTrackSink implementation. Called on the main thread. |
| 66 void DoRenderFrameOnMainThread(scoped_refptr<media::VideoFrame> video_frame); | 56 virtual void OnVideoFrame( |
| 57 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; |
| 58 virtual void OnReadyStateChanged( |
| 59 blink::WebMediaStreamSource::ReadyState state) OVERRIDE; |
| 60 |
| 61 void MaybeRenderSignalingFrame( |
| 62 blink::WebMediaStreamSource::ReadyState state); |
| 67 | 63 |
| 68 base::Closure error_cb_; | 64 base::Closure error_cb_; |
| 69 RepaintCB repaint_cb_; | 65 RepaintCB repaint_cb_; |
| 70 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 66 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| 71 State state_; | 67 State state_; |
| 72 | 68 blink::WebMediaStreamTrack video_track_; |
| 73 // The video track the renderer is connected to. | |
| 74 scoped_refptr<webrtc::VideoTrackInterface> video_track_; | |
| 75 | 69 |
| 76 DISALLOW_COPY_AND_ASSIGN(RTCVideoRenderer); | 70 DISALLOW_COPY_AND_ASSIGN(RTCVideoRenderer); |
| 77 }; | 71 }; |
| 78 | 72 |
| 79 } // namespace content | 73 } // namespace content |
| 80 | 74 |
| 81 #endif // CONTENT_RENDERER_MEDIA_LOCAL_VIDEO_RENDERER_H_ | 75 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_RENDERER_H_ |
| OLD | NEW |