Add ICU message format support
[chromium-blink-merge.git] / content / renderer / media / media_stream.h
blob6a43cfc4cddb5bb5d7c8f8bf9991cbaafd8fdd7c
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_MEDIA_STREAM_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/threading/thread_checker.h"
14 #include "content/common/content_export.h"
15 #include "third_party/WebKit/public/platform/WebMediaStream.h"
17 namespace webrtc {
18 class MediaStreamInterface;
21 namespace content {
23 // MediaStreamObserver can be used to get notifications of when a track is
24 // added or removed from a MediaStream.
25 class MediaStreamObserver {
26 public:
27 // TrackAdded is called |track| is added to the observed MediaStream.
28 virtual void TrackAdded(const blink::WebMediaStreamTrack& track) = 0;
29 // TrackRemoved is called |track| is added to the observed MediaStream.
30 virtual void TrackRemoved(const blink::WebMediaStreamTrack& track) = 0;
32 protected:
33 virtual ~MediaStreamObserver() {}
36 // MediaStream is the Chrome representation of blink::WebMediaStream.
37 // It is owned by blink::WebMediaStream as blink::WebMediaStream::ExtraData.
38 // Its lifetime is the same as the blink::WebMediaStream instance it belongs to.
39 class CONTENT_EXPORT MediaStream
40 : NON_EXPORTED_BASE(public blink::WebMediaStream::ExtraData) {
41 public:
42 // Constructor for local MediaStreams.
43 MediaStream(const blink::WebMediaStream& stream);
45 // Constructor for remote MediaStreams.
46 // TODO(xians): Remove once the audio renderer don't separate between local
47 // and remotely generated streams.
48 explicit MediaStream(webrtc::MediaStreamInterface* webrtc_stream);
50 virtual ~MediaStream();
52 // Returns an instance of MediaStream. This method will never return NULL.
53 static MediaStream* GetMediaStream(
54 const blink::WebMediaStream& stream);
56 // Returns a libjingle representation of a remote MediaStream.
57 // TODO(xians): Remove once the audio renderer don't separate between local
58 // and remotely generated streams.
59 static webrtc::MediaStreamInterface* GetAdapter(
60 const blink::WebMediaStream& stream);
62 // Adds an observer to this MediaStream. Its the callers responsibility to
63 // remove the observer before the destruction of the MediaStream.
64 void AddObserver(MediaStreamObserver* observer);
65 void RemoveObserver(MediaStreamObserver* observer);
67 // TODO(xians): Remove |is_local| once AudioTracks can be rendered the same
68 // way regardless if they are local or remote.
69 bool is_local() const { return is_local_; }
71 // Called by MediaStreamCenter when a track has been added to a stream stream.
72 bool AddTrack(const blink::WebMediaStreamTrack& track);
74 // Called by MediaStreamCenter when a track has been removed from |stream|.
75 bool RemoveTrack(const blink::WebMediaStreamTrack& track);
77 protected:
78 virtual webrtc::MediaStreamInterface* GetWebRtcAdapter(
79 const blink::WebMediaStream& stream);
81 private:
82 base::ThreadChecker thread_checker_;
83 const bool is_local_;
84 const std::string label_;
85 std::vector<MediaStreamObserver*> observers_;
87 // TODO(xians): Remove once the audio renderer don't separate between local
88 // and remotely generated streams.
89 scoped_refptr<webrtc::MediaStreamInterface> webrtc_media_stream_;
91 DISALLOW_COPY_AND_ASSIGN(MediaStream);
94 } // namespace content
96 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_H_