| OLD | NEW |
| 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_ |
| OLD | NEW |