1 // Copyright 2014 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.
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_
8 #include "base/threading/thread_checker.h"
9 #include "content/common/content_export.h"
10 #include "content/renderer/media/media_stream_video_source.h"
11 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
12 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
16 // MediaStreamRemoteVideoSource implements the MediaStreamVideoSource interface
17 // for video tracks received on a PeerConnection. The purpose of the class is
18 // to make sure there is no difference between a video track where the source is
19 // a local source and a video track where the source is a remote video track.
20 class CONTENT_EXPORT MediaStreamRemoteVideoSource
21 : public MediaStreamVideoSource
,
22 NON_EXPORTED_BASE(public webrtc::ObserverInterface
) {
24 explicit MediaStreamRemoteVideoSource(
25 webrtc::VideoTrackInterface
* remote_track
);
26 virtual ~MediaStreamRemoteVideoSource();
29 // Implements MediaStreamVideoSource.
30 void GetCurrentSupportedFormats(
31 int max_requested_width
,
32 int max_requested_height
,
33 double max_requested_frame_rate
,
34 const VideoCaptureDeviceFormatsCB
& callback
) override
;
37 const media::VideoCaptureFormat
& format
,
38 const VideoCaptureDeliverFrameCB
& frame_callback
) override
;
40 void StopSourceImpl() override
;
42 // Used by tests to test that a frame can be received and that the
43 // MediaStreamRemoteVideoSource behaves as expected.
44 webrtc::VideoRendererInterface
* RenderInterfaceForTest();
47 // webrtc::ObserverInterface implementation.
48 void OnChanged() override
;
50 scoped_refptr
<webrtc::VideoTrackInterface
> remote_track_
;
51 webrtc::MediaStreamTrackInterface::TrackState last_state_
;
53 // Internal class used for receiving frames from the webrtc track on a
54 // libjingle thread and forward it to the IO-thread.
55 class RemoteVideoSourceDelegate
;
56 scoped_refptr
<RemoteVideoSourceDelegate
> delegate_
;
58 // Bound to the render thread.
59 base::ThreadChecker thread_checker_
;
61 DISALLOW_COPY_AND_ASSIGN(MediaStreamRemoteVideoSource
);
64 } // namespace content
66 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_