Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / renderer / media / webrtc / media_stream_remote_video_source.h
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.
4
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_
7
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"
12
13 namespace content {
14
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) {
22  public:
23   explicit MediaStreamRemoteVideoSource(
24       webrtc::VideoTrackInterface* remote_track);
25   virtual ~MediaStreamRemoteVideoSource();
26
27  protected:
28   // Implements MediaStreamVideoSource.
29   virtual void GetCurrentSupportedFormats(
30       int max_requested_width,
31       int max_requested_height,
32       const VideoCaptureDeviceFormatsCB& callback) OVERRIDE;
33
34   virtual void StartSourceImpl(
35       const media::VideoCaptureParams& params,
36       const VideoCaptureDeliverFrameCB& frame_callback) OVERRIDE;
37
38   virtual void StopSourceImpl() OVERRIDE;
39
40   // Used by tests to test that a frame can be received and that the
41   // MediaStreamRemoteVideoSource behaves as expected.
42   webrtc::VideoRendererInterface* RenderInterfaceForTest();
43
44  private:
45   // webrtc::ObserverInterface implementation.
46   virtual void OnChanged() OVERRIDE;
47
48   scoped_refptr<webrtc::VideoTrackInterface> remote_track_;
49   webrtc::MediaStreamTrackInterface::TrackState last_state_;
50
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_;
55
56   // Bound to the render thread.
57   base::ThreadChecker thread_checker_;
58
59   DISALLOW_COPY_AND_ASSIGN(MediaStreamRemoteVideoSource);
60 };
61
62 }  // namespace content
63
64 #endif  // CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_