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_WEBRTC_VIDEO_TRACK_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_TRACK_ADAPTER_H_
8 #include "base/macros.h"
9 #include "base/threading/thread_checker.h"
10 #include "content/public/renderer/media_stream_video_sink.h"
11 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
12 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
14 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
15 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h"
19 class MediaStreamVideoTrack
;
21 // WebRtcVideoTrackAdapter is an adapter between a
22 // content::MediaStreamVideoTrack object and a webrtc VideoTrack that is
23 // currently sent on a PeerConnection.
24 // The responsibility of the class is to create and own a representation of a
25 // webrtc VideoTrack that can be added and removed from a RTCPeerConnection.
26 // An instance of WebRtcVideoTrackAdapter is created when a VideoTrack is
27 // added to an RTCPeerConnection object.
28 // Instances of this class is owned by the WebRtcMediaStreamAdapter object that
30 class WebRtcVideoTrackAdapter
: public MediaStreamVideoSink
{
32 WebRtcVideoTrackAdapter(const blink::WebMediaStreamTrack
& track
,
33 PeerConnectionDependencyFactory
* factory
);
34 ~WebRtcVideoTrackAdapter() override
;
36 webrtc::VideoTrackInterface
* webrtc_video_track() {
37 return video_track_
.get();
41 // Implementation of MediaStreamSink.
42 void OnEnabledChanged(bool enabled
) override
;
45 // Used to DCHECK that we are called on the correct thread.
46 base::ThreadChecker thread_checker_
;
48 scoped_refptr
<webrtc::VideoTrackInterface
> video_track_
;
49 blink::WebMediaStreamTrack web_track_
;
51 class WebRtcVideoSourceAdapter
;
52 scoped_refptr
<WebRtcVideoSourceAdapter
> source_adapter_
;
54 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoTrackAdapter
);
57 } // namespace content
59 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_TRACK_ADAPTER_H_