Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: webrtc/api/streamcollection.h

Issue 2514883002: Create //webrtc/api:libjingle_peerconnection_api + refactorings. (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/statstypes.cc ('k') | webrtc/api/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_API_STREAMCOLLECTION_H_ 11 #ifndef WEBRTC_API_STREAMCOLLECTION_H_
12 #define WEBRTC_API_STREAMCOLLECTION_H_ 12 #define WEBRTC_API_STREAMCOLLECTION_H_
13 13
14 #include <string> 14 // Including this file is deprecated. It is no longer part of the public API.
15 #include <vector> 15 // This only includes the file in its new location for backwards compatibility.
16 16 #include "webrtc/pc/streamcollection.h"
17 #include "webrtc/api/peerconnectioninterface.h"
18
19 namespace webrtc {
20
21 // Implementation of StreamCollection.
22 class StreamCollection : public StreamCollectionInterface {
23 public:
24 static rtc::scoped_refptr<StreamCollection> Create() {
25 rtc::RefCountedObject<StreamCollection>* implementation =
26 new rtc::RefCountedObject<StreamCollection>();
27 return implementation;
28 }
29
30 static rtc::scoped_refptr<StreamCollection> Create(
31 StreamCollection* streams) {
32 rtc::RefCountedObject<StreamCollection>* implementation =
33 new rtc::RefCountedObject<StreamCollection>(streams);
34 return implementation;
35 }
36
37 virtual size_t count() {
38 return media_streams_.size();
39 }
40
41 virtual MediaStreamInterface* at(size_t index) {
42 return media_streams_.at(index);
43 }
44
45 virtual MediaStreamInterface* find(const std::string& label) {
46 for (StreamVector::iterator it = media_streams_.begin();
47 it != media_streams_.end(); ++it) {
48 if ((*it)->label().compare(label) == 0) {
49 return (*it);
50 }
51 }
52 return NULL;
53 }
54
55 virtual MediaStreamTrackInterface* FindAudioTrack(
56 const std::string& id) {
57 for (size_t i = 0; i < media_streams_.size(); ++i) {
58 MediaStreamTrackInterface* track = media_streams_[i]->FindAudioTrack(id);
59 if (track) {
60 return track;
61 }
62 }
63 return NULL;
64 }
65
66 virtual MediaStreamTrackInterface* FindVideoTrack(
67 const std::string& id) {
68 for (size_t i = 0; i < media_streams_.size(); ++i) {
69 MediaStreamTrackInterface* track = media_streams_[i]->FindVideoTrack(id);
70 if (track) {
71 return track;
72 }
73 }
74 return NULL;
75 }
76
77 void AddStream(MediaStreamInterface* stream) {
78 for (StreamVector::iterator it = media_streams_.begin();
79 it != media_streams_.end(); ++it) {
80 if ((*it)->label().compare(stream->label()) == 0)
81 return;
82 }
83 media_streams_.push_back(stream);
84 }
85
86 void RemoveStream(MediaStreamInterface* remove_stream) {
87 for (StreamVector::iterator it = media_streams_.begin();
88 it != media_streams_.end(); ++it) {
89 if ((*it)->label().compare(remove_stream->label()) == 0) {
90 media_streams_.erase(it);
91 break;
92 }
93 }
94 }
95
96 protected:
97 StreamCollection() {}
98 explicit StreamCollection(StreamCollection* original)
99 : media_streams_(original->media_streams_) {
100 }
101 typedef std::vector<rtc::scoped_refptr<MediaStreamInterface> >
102 StreamVector;
103 StreamVector media_streams_;
104 };
105
106 } // namespace webrtc
107 17
108 #endif // WEBRTC_API_STREAMCOLLECTION_H_ 18 #endif // WEBRTC_API_STREAMCOLLECTION_H_
OLDNEW
« no previous file with comments | « webrtc/api/statstypes.cc ('k') | webrtc/api/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698