1// Copyright (c) 2012 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_REMOTE_MEDIA_STREAM_IMPL_H_
6#define CONTENT_RENDERER_MEDIA_REMOTE_MEDIA_STREAM_IMPL_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "base/memory/ref_counted.h"
11#include "base/memory/scoped_vector.h"
12#include "base/threading/non_thread_safe.h"
13#include "content/common/content_export.h"
14#include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
15#include "third_party/WebKit/public/platform/WebMediaStream.h"
16#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
17#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
18
19namespace content {
20
21class RemoteMediaStreamTrackAdapter;
22
23// RemoteMediaStreamImpl serves as a container and glue between remote webrtc
24// MediaStreams and WebKit MediaStreams. For each remote MediaStream received
25// on a PeerConnection a RemoteMediaStreamImpl instance is created and
26// owned by RtcPeerConnection.
27class CONTENT_EXPORT RemoteMediaStreamImpl
28    : NON_EXPORTED_BASE(public webrtc::ObserverInterface),
29      NON_EXPORTED_BASE(public base::NonThreadSafe) {
30 public:
31  explicit RemoteMediaStreamImpl(
32      webrtc::MediaStreamInterface* webrtc_stream);
33  virtual ~RemoteMediaStreamImpl();
34
35  const blink::WebMediaStream& webkit_stream() { return webkit_stream_; }
36
37 private:
38  // webrtc::ObserverInterface implementation.
39  virtual void OnChanged() OVERRIDE;
40
41  scoped_refptr<webrtc::MediaStreamInterface> webrtc_stream_;
42  ScopedVector<RemoteMediaStreamTrackAdapter> video_track_observers_;
43  ScopedVector<RemoteMediaStreamTrackAdapter> audio_track_observers_;
44  blink::WebMediaStream webkit_stream_;
45
46  DISALLOW_COPY_AND_ASSIGN(RemoteMediaStreamImpl);
47};
48
49}  // namespace content
50
51#endif  // CONTENT_RENDERER_MEDIA_REMOTE_MEDIA_STREAM_IMPL_H_
52