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/memory/weak_ptr.h"
9 #include "base/single_thread_task_runner.h"
10 #include "content/common/content_export.h"
11 #include "content/renderer/media/media_stream_video_source.h"
12 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
19 // MediaStreamRemoteVideoSource implements the MediaStreamVideoSource interface
20 // for video tracks received on a PeerConnection. The purpose of the class is
21 // to make sure there is no difference between a video track where the source is
22 // a local source and a video track where the source is a remote video track.
23 class CONTENT_EXPORT MediaStreamRemoteVideoSource
24 : public MediaStreamVideoSource
{
26 MediaStreamRemoteVideoSource(scoped_ptr
<TrackObserver
> observer
);
27 virtual ~MediaStreamRemoteVideoSource();
30 // Implements MediaStreamVideoSource.
31 void GetCurrentSupportedFormats(
32 int max_requested_width
,
33 int max_requested_height
,
34 double max_requested_frame_rate
,
35 const VideoCaptureDeviceFormatsCB
& callback
) override
;
38 const media::VideoCaptureFormat
& format
,
39 const VideoCaptureDeliverFrameCB
& frame_callback
) override
;
41 void StopSourceImpl() override
;
43 // Used by tests to test that a frame can be received and that the
44 // MediaStreamRemoteVideoSource behaves as expected.
45 webrtc::VideoRendererInterface
* RenderInterfaceForTest();
48 void OnChanged(webrtc::MediaStreamTrackInterface::TrackState state
);
50 // Internal class used for receiving frames from the webrtc track on a
51 // libjingle thread and forward it to the IO-thread.
52 class RemoteVideoSourceDelegate
;
53 scoped_refptr
<RemoteVideoSourceDelegate
> delegate_
;
54 scoped_ptr
<TrackObserver
> observer_
;
56 DISALLOW_COPY_AND_ASSIGN(MediaStreamRemoteVideoSource
);
59 } // namespace content
61 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_