OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_LOCAL_VIDEO_RENDERER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_LOCAL_VIDEO_RENDERER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 11 #include "ui/gfx/size.h" |
| 12 #include "webkit/media/video_frame_provider.h" |
| 13 |
| 14 namespace base { |
| 15 class MessageLoopProxy; |
| 16 } |
| 17 |
| 18 namespace content { |
| 19 |
| 20 // RTCVideoRenderer is a webkit_media::VideoFrameProvider designed for rendering |
| 21 // Video MediaStreamTracks, |
| 22 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamtrack |
| 23 // RTCVideoRenderer implements webrtc::VideoRendererInterface in order to render |
| 24 // video frames provided from a webrtc::VideoTrackInteface. |
| 25 // RTCVideoRenderer register itself to the Video Track when the |
| 26 // VideoFrameProvider is started and deregisters itself when it is stopped. |
| 27 // Calls to webrtc::VideoTrackInterface must occur on the main thread. |
| 28 class CONTENT_EXPORT RTCVideoRenderer |
| 29 : NON_EXPORTED_BASE(public webkit_media::VideoFrameProvider), |
| 30 NON_EXPORTED_BASE(public webrtc::VideoRendererInterface) { |
| 31 public: |
| 32 RTCVideoRenderer( |
| 33 webrtc::VideoTrackInterface* video_track, |
| 34 const base::Closure& error_cb, |
| 35 const RepaintCB& repaint_cb); |
| 36 |
| 37 // webkit_media::VideoFrameProvider implementation. Called on the main thread. |
| 38 virtual void Start() OVERRIDE; |
| 39 virtual void Stop() OVERRIDE; |
| 40 virtual void Play() OVERRIDE; |
| 41 virtual void Pause() OVERRIDE; |
| 42 |
| 43 // webrtc::VideoRendererInterface implementation. May be called on |
| 44 // a different thread. |
| 45 virtual void SetSize(int width, int height) OVERRIDE; |
| 46 virtual void RenderFrame(const cricket::VideoFrame* frame) OVERRIDE; |
| 47 |
| 48 protected: |
| 49 virtual ~RTCVideoRenderer(); |
| 50 |
| 51 private: |
| 52 enum State { |
| 53 kStarted, |
| 54 kPaused, |
| 55 kStopped, |
| 56 }; |
| 57 |
| 58 void DoRenderFrameOnMainThread(scoped_refptr<media::VideoFrame> video_frame); |
| 59 |
| 60 base::Closure error_cb_; |
| 61 RepaintCB repaint_cb_; |
| 62 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| 63 State state_; |
| 64 |
| 65 // The video track the renderer is connected to. |
| 66 scoped_refptr<webrtc::VideoTrackInterface> video_track_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(RTCVideoRenderer); |
| 69 }; |
| 70 |
| 71 } // namespace content |
| 72 |
| 73 #endif // CONTENT_RENDERER_MEDIA_LOCAL_VIDEO_RENDERER_H_ |
OLD | NEW |