OLD | NEW |
| (Empty) |
1 // Copyright 2013 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_WEBRTC_VIDEO_SINK_ADAPTER_H_ | |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_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 | |
20 // webrtc:::VideoTrackInterface and a content::MediaStreamVideoSink. | |
21 // It is responsible for translating video data from a libjingle video type | |
22 // to a chrome video type. | |
23 class CONTENT_EXPORT WebRtcVideoSinkAdapter | |
24 : NON_EXPORTED_BASE(public webrtc::VideoRendererInterface), | |
25 NON_EXPORTED_BASE(public webrtc::ObserverInterface), | |
26 public base::SupportsWeakPtr<WebRtcVideoSinkAdapter> { | |
27 public: | |
28 WebRtcVideoSinkAdapter(webrtc::VideoTrackInterface* video_track, | |
29 MediaStreamVideoSink* sink); | |
30 virtual ~WebRtcVideoSinkAdapter(); | |
31 | |
32 MediaStreamVideoSink* sink() const { return sink_; } | |
33 | |
34 protected: | |
35 // webrtc::VideoRendererInterface implementation. May be called on | |
36 // a different thread. | |
37 virtual void SetSize(int width, int height) OVERRIDE; | |
38 virtual void RenderFrame(const cricket::VideoFrame* frame) OVERRIDE; | |
39 | |
40 // webrtc::ObserverInterface implementation. | |
41 // TODO(perkj): OnChanged should be implemented on a common base class used | |
42 // for both WebRtc Audio and Video tracks. | |
43 virtual void OnChanged() OVERRIDE; | |
44 | |
45 private: | |
46 void DoRenderFrameOnMainThread(scoped_refptr<media::VideoFrame> video_frame); | |
47 | |
48 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | |
49 MediaStreamVideoSink* sink_; | |
50 // The video track the renderer is connected to. | |
51 scoped_refptr<webrtc::VideoTrackInterface> video_track_; | |
52 webrtc::MediaStreamTrackInterface::TrackState state_; | |
53 bool track_enabled_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoSinkAdapter); | |
56 }; | |
57 | |
58 } // namespace content | |
59 | |
60 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_SINK_ADAPTER_H_ | |
OLD | NEW |