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_WEBRTC_VIDEO_SINK_ADAPTER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_SINK_ADAPTER_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "content/public/renderer/media_stream_video_sink.h" |
| 11 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 12 |
| 13 namespace base { |
| 14 class MessageLoopProxy; |
| 15 } |
| 16 |
| 17 namespace content { |
| 18 |
| 19 // WebRtcVideoSinkAdapter acts as the middle man between a WebRtc |
| 20 // implementation of a MediaStream VideoTrack and a |
| 21 // content::MediaStreamVideoSink. |
| 22 // It is responsible for translating video data from the libjingle video types |
| 23 // to chrome video types. |
| 24 class CONTENT_EXPORT WebRtcVideoSinkAdapter |
| 25 : NON_EXPORTED_BASE(public webrtc::VideoRendererInterface), |
| 26 NON_EXPORTED_BASE(public webrtc::ObserverInterface), |
| 27 public base::SupportsWeakPtr<WebRtcVideoSinkAdapter> { |
| 28 public: |
| 29 WebRtcVideoSinkAdapter(webrtc::VideoTrackInterface* video_track, |
| 30 MediaStreamVideoSink* sink); |
| 31 virtual ~WebRtcVideoSinkAdapter(); |
| 32 |
| 33 MediaStreamVideoSink* sink() const { return sink_; } |
| 34 |
| 35 protected: |
| 36 // webrtc::VideoRendererInterface implementation. May be called on |
| 37 // a different thread. |
| 38 virtual void SetSize(int width, int height) OVERRIDE; |
| 39 virtual void RenderFrame(const cricket::VideoFrame* frame) OVERRIDE; |
| 40 |
| 41 // webrtc::ObserverInterface implementation. |
| 42 // TODO(perkj): OnChanged should be implemented on a common base class used |
| 43 // for both WebRtc Audio and Video tracks. |
| 44 virtual void OnChanged() OVERRIDE; |
| 45 |
| 46 private: |
| 47 void DoRenderFrameOnMainThread(scoped_refptr<media::VideoFrame> video_frame); |
| 48 |
| 49 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| 50 MediaStreamVideoSink* sink_; |
| 51 // The video track the renderer is connected to. |
| 52 scoped_refptr<webrtc::VideoTrackInterface> video_track_; |
| 53 webrtc::MediaStreamTrackInterface::TrackState state_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoSinkAdapter); |
| 56 }; |
| 57 |
| 58 } // namespace content |
| 59 |
| 60 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_SINK_ADAPTER_H_ |
OLD | NEW |