| 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 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea
mSourceVector& audioSources, const MediaStreamSourceVector& videoSources) | 40 MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamSourceVect
or& audioSources, const MediaStreamSourceVector& videoSources) |
| 41 { | 41 { |
| 42 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audio
Sources, videoSources)); | 42 return new MediaStreamDescriptor(createCanonicalUUIDString(), audioSources,
videoSources); |
| 43 } | 43 } |
| 44 | 44 |
| 45 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea
mComponentVector& audioComponents, const MediaStreamComponentVector& videoCompon
ents) | 45 MediaStreamDescriptor* MediaStreamDescriptor::create(const MediaStreamComponentV
ector& audioComponents, const MediaStreamComponentVector& videoComponents) |
| 46 { | 46 { |
| 47 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audio
Components, videoComponents)); | 47 return new MediaStreamDescriptor(createCanonicalUUIDString(), audioComponent
s, videoComponents); |
| 48 } | 48 } |
| 49 | 49 |
| 50 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const String& id
, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentV
ector& videoComponents) | 50 MediaStreamDescriptor* MediaStreamDescriptor::create(const String& id, const Med
iaStreamComponentVector& audioComponents, const MediaStreamComponentVector& vide
oComponents) |
| 51 { | 51 { |
| 52 return adoptRef(new MediaStreamDescriptor(id, audioComponents, videoComponen
ts)); | 52 return new MediaStreamDescriptor(id, audioComponents, videoComponents); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void MediaStreamDescriptor::addComponent(PassRefPtr<MediaStreamComponent> compon
ent) | 55 void MediaStreamDescriptor::addComponent(MediaStreamComponent* component) |
| 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(PassRefPtr<MediaStreamComponent> com
ponent) | 69 void MediaStreamDescriptor::removeComponent(MediaStreamComponent* component) |
| 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(0) | 103 : m_client(nullptr) |
| 104 , m_id(id) | 104 , m_id(id) |
| 105 , m_active(true) | 105 , m_active(true) |
| 106 , m_ended(false) | 106 , m_ended(false) |
| 107 { | 107 { |
| 108 ASSERT(m_id.length()); | 108 ASSERT(m_id.length()); |
| 109 for (size_t i = 0; i < audioSources.size(); i++) | 109 for (size_t i = 0; i < audioSources.size(); i++) |
| 110 m_audioComponents.append(MediaStreamComponent::create(audioSources[i])); | 110 m_audioComponents.append(MediaStreamComponent::create(audioSources[i])); |
| 111 | 111 |
| 112 for (size_t i = 0; i < videoSources.size(); i++) | 112 for (size_t i = 0; i < videoSources.size(); i++) |
| 113 m_videoComponents.append(MediaStreamComponent::create(videoSources[i])); | 113 m_videoComponents.append(MediaStreamComponent::create(videoSources[i])); |
| 114 } | 114 } |
| 115 | 115 |
| 116 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream
ComponentVector& audioComponents, const MediaStreamComponentVector& videoCompone
nts) | 116 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream
ComponentVector& audioComponents, const MediaStreamComponentVector& videoCompone
nts) |
| 117 : m_client(0) | 117 : m_client(nullptr) |
| 118 , m_id(id) | 118 , m_id(id) |
| 119 , m_active(true) | 119 , m_active(true) |
| 120 , m_ended(false) | 120 , m_ended(false) |
| 121 { | 121 { |
| 122 ASSERT(m_id.length()); | 122 ASSERT(m_id.length()); |
| 123 for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin
(); iter != audioComponents.end(); ++iter) | 123 for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin
(); iter != audioComponents.end(); ++iter) |
| 124 m_audioComponents.append((*iter)); | 124 m_audioComponents.append((*iter)); |
| 125 for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin
(); iter != videoComponents.end(); ++iter) | 125 for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin
(); iter != videoComponents.end(); ++iter) |
| 126 m_videoComponents.append((*iter)); | 126 m_videoComponents.append((*iter)); |
| 127 } | 127 } |
| 128 | 128 |
| 129 DEFINE_TRACE(MediaStreamDescriptor) |
| 130 { |
| 131 visitor->trace(m_audioComponents); |
| 132 visitor->trace(m_videoComponents); |
| 133 visitor->trace(m_client); |
| 134 } |
| 135 |
| 129 } // namespace blink | 136 } // namespace blink |
| 130 | |
| OLD | NEW |