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 "content/common/content_export.h"
9 #include "content/renderer/media/media_stream_video_source.h"
10 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
11 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
15 // MediaStreamRemoteVideoSource implements the MediaStreamVideoSource interface
16 // for video tracks received on a PeerConnection. The purpose of the class is
17 // to make sure there is no difference between a video track where the source is
18 // a local source and a video track where the source is a remote video track.
19 class CONTENT_EXPORT MediaStreamRemoteVideoSource
20 : public MediaStreamVideoSource,
21 NON_EXPORTED_BASE(public webrtc::ObserverInterface) {
23 explicit MediaStreamRemoteVideoSource(
24 webrtc::VideoTrackInterface* remote_track);
25 virtual ~MediaStreamRemoteVideoSource();
28 // Implements MediaStreamVideoSource.
29 virtual void GetCurrentSupportedFormats(
30 int max_requested_width,
31 int max_requested_height,
32 const VideoCaptureDeviceFormatsCB& callback) OVERRIDE;
34 virtual void StartSourceImpl(
35 const media::VideoCaptureParams& params,
36 const VideoCaptureDeliverFrameCB& frame_callback) OVERRIDE;
38 virtual void StopSourceImpl() OVERRIDE;
40 // Used by tests to test that a frame can be received and that the
41 // MediaStreamRemoteVideoSource behaves as expected.
42 webrtc::VideoRendererInterface* RenderInterfaceForTest();
45 // webrtc::ObserverInterface implementation.
46 virtual void OnChanged() OVERRIDE;
48 scoped_refptr<webrtc::VideoTrackInterface> remote_track_;
49 webrtc::MediaStreamTrackInterface::TrackState last_state_;
51 // Internal class used for receiving frames from the webrtc track on a
52 // libjingle thread and forward it to the IO-thread.
53 class RemoteVideoSourceDelegate;
54 scoped_refptr<RemoteVideoSourceDelegate> delegate_;
56 // Bound to the render thread.
57 base::ThreadChecker thread_checker_;
59 DISALLOW_COPY_AND_ASSIGN(MediaStreamRemoteVideoSource);
62 } // namespace content
64 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_