OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 19 matching lines...) Expand all Loading... |
30 */ | 30 */ |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 | 33 |
34 #include "platform/mediastream/MediaStreamDescriptor.h" | 34 #include "platform/mediastream/MediaStreamDescriptor.h" |
35 | 35 |
36 #include "platform/UUID.h" | 36 #include "platform/UUID.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamSourceVect
or& audioSources, const MediaStreamSourceVector& videoSources) | 40 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea
mSourceVector& audioSources, const MediaStreamSourceVector& videoSources) |
41 { | 41 { |
42 return new MediaStreamDescriptor(createCanonicalUUIDString(), audioSources,
videoSources); | 42 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audio
Sources, videoSources)); |
43 } | 43 } |
44 | 44 |
45 MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamComponentV
ector& audioComponents, const MediaStreamComponentVector& videoComponents) | 45 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea
mComponentVector& audioComponents, const MediaStreamComponentVector& videoCompon
ents) |
46 { | 46 { |
47 return new MediaStreamDescriptor(createCanonicalUUIDString(), audioComponent
s, videoComponents); | 47 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audio
Components, videoComponents)); |
48 } | 48 } |
49 | 49 |
50 MediaStreamDescriptor* MediaStreamDescriptor::create(const String& id, const Med
iaStreamComponentVector& audioComponents, const MediaStreamComponentVector& vide
oComponents) | 50 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const String& id
, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentV
ector& videoComponents) |
51 { | 51 { |
52 return new MediaStreamDescriptor(id, audioComponents, videoComponents); | 52 return adoptRef(new MediaStreamDescriptor(id, audioComponents, videoComponen
ts)); |
53 } | 53 } |
54 | 54 |
55 void MediaStreamDescriptor::addComponent(MediaStreamComponent* component) | 55 void MediaStreamDescriptor::addComponent(PassRefPtr<MediaStreamComponent> compon
ent) |
56 { | 56 { |
57 switch (component->source()->type()) { | 57 switch (component->source()->type()) { |
58 case MediaStreamSource::TypeAudio: | 58 case MediaStreamSource::TypeAudio: |
59 if (m_audioComponents.find(component) == kNotFound) | 59 if (m_audioComponents.find(component) == kNotFound) |
60 m_audioComponents.append(component); | 60 m_audioComponents.append(component); |
61 break; | 61 break; |
62 case MediaStreamSource::TypeVideo: | 62 case MediaStreamSource::TypeVideo: |
63 if (m_videoComponents.find(component) == kNotFound) | 63 if (m_videoComponents.find(component) == kNotFound) |
64 m_videoComponents.append(component); | 64 m_videoComponents.append(component); |
65 break; | 65 break; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void MediaStreamDescriptor::removeComponent(MediaStreamComponent* component) | 69 void MediaStreamDescriptor::removeComponent(PassRefPtr<MediaStreamComponent> com
ponent) |
70 { | 70 { |
71 size_t pos = kNotFound; | 71 size_t pos = kNotFound; |
72 switch (component->source()->type()) { | 72 switch (component->source()->type()) { |
73 case MediaStreamSource::TypeAudio: | 73 case MediaStreamSource::TypeAudio: |
74 pos = m_audioComponents.find(component); | 74 pos = m_audioComponents.find(component); |
75 if (pos != kNotFound) | 75 if (pos != kNotFound) |
76 m_audioComponents.remove(pos); | 76 m_audioComponents.remove(pos); |
77 break; | 77 break; |
78 case MediaStreamSource::TypeVideo: | 78 case MediaStreamSource::TypeVideo: |
79 pos = m_videoComponents.find(component); | 79 pos = m_videoComponents.find(component); |
(...skipping 13 matching lines...) Expand all Loading... |
93 | 93 |
94 void MediaStreamDescriptor::removeRemoteTrack(MediaStreamComponent* component) | 94 void MediaStreamDescriptor::removeRemoteTrack(MediaStreamComponent* component) |
95 { | 95 { |
96 if (m_client) | 96 if (m_client) |
97 m_client->removeRemoteTrack(component); | 97 m_client->removeRemoteTrack(component); |
98 else | 98 else |
99 removeComponent(component); | 99 removeComponent(component); |
100 } | 100 } |
101 | 101 |
102 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream
SourceVector& audioSources, const MediaStreamSourceVector& videoSources) | 102 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream
SourceVector& audioSources, const MediaStreamSourceVector& videoSources) |
103 : m_client(nullptr) | 103 : m_client(0) |
104 , m_id(id) | 104 , m_id(id) |
105 , m_ended(false) | 105 , m_ended(false) |
106 { | 106 { |
107 ASSERT(m_id.length()); | 107 ASSERT(m_id.length()); |
108 for (size_t i = 0; i < audioSources.size(); i++) | 108 for (size_t i = 0; i < audioSources.size(); i++) |
109 m_audioComponents.append(MediaStreamComponent::create(audioSources[i])); | 109 m_audioComponents.append(MediaStreamComponent::create(audioSources[i])); |
110 | 110 |
111 for (size_t i = 0; i < videoSources.size(); i++) | 111 for (size_t i = 0; i < videoSources.size(); i++) |
112 m_videoComponents.append(MediaStreamComponent::create(videoSources[i])); | 112 m_videoComponents.append(MediaStreamComponent::create(videoSources[i])); |
113 } | 113 } |
114 | 114 |
115 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream
ComponentVector& audioComponents, const MediaStreamComponentVector& videoCompone
nts) | 115 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream
ComponentVector& audioComponents, const MediaStreamComponentVector& videoCompone
nts) |
116 : m_client(nullptr) | 116 : m_client(0) |
117 , m_id(id) | 117 , m_id(id) |
118 , m_ended(false) | 118 , m_ended(false) |
119 { | 119 { |
120 ASSERT(m_id.length()); | 120 ASSERT(m_id.length()); |
121 for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin
(); iter != audioComponents.end(); ++iter) | 121 for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin
(); iter != audioComponents.end(); ++iter) |
122 m_audioComponents.append((*iter)); | 122 m_audioComponents.append((*iter)); |
123 for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin
(); iter != videoComponents.end(); ++iter) | 123 for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin
(); iter != videoComponents.end(); ++iter) |
124 m_videoComponents.append((*iter)); | 124 m_videoComponents.append((*iter)); |
125 } | 125 } |
126 | 126 |
127 void MediaStreamDescriptor::trace(Visitor* visitor) | |
128 { | |
129 visitor->trace(m_audioComponents); | |
130 visitor->trace(m_videoComponents); | |
131 visitor->trace(m_client); | |
132 } | |
133 | |
134 } // namespace blink | 127 } // namespace blink |
135 | 128 |
OLD | NEW |