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

Side by Side Diff: Source/core/platform/mediastream/MediaStreamDescriptor.cpp

Issue 14989002: Splitting MediaStreamDescriptor.h and MediaStreamComponent.h into .h and .cpp (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/platform/mediastream/MediaStreamDescriptor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include "config.h"
33
34 #include "core/platform/mediastream/MediaStreamDescriptor.h"
35
36 #include "core/platform/UUID.h"
37 #include "core/platform/mediastream/MediaStreamComponent.h"
38 #include "core/platform/mediastream/MediaStreamSource.h"
39 #include <wtf/RefCounted.h>
40 #include <wtf/Vector.h>
41
42 namespace WebCore {
43
44 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea mSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
45 {
46 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audio Sources, videoSources));
47 }
48
49 PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const String& id , const MediaStreamComponentVector& audioComponents, const MediaStreamComponentV ector& videoComponents)
50 {
51 return adoptRef(new MediaStreamDescriptor(id, audioComponents, videoComponen ts));
52 }
53
54 void MediaStreamDescriptor::addComponent(PassRefPtr<MediaStreamComponent> compon ent)
55 {
56 switch (component->source()->type()) {
57 case MediaStreamSource::TypeAudio:
58 if (m_audioComponents.find(component) == notFound)
59 m_audioComponents.append(component);
60 break;
61 case MediaStreamSource::TypeVideo:
62 if (m_videoComponents.find(component) == notFound)
63 m_videoComponents.append(component);
64 break;
65 }
66 }
67
68 void MediaStreamDescriptor::removeComponent(PassRefPtr<MediaStreamComponent> com ponent)
69 {
70 size_t pos = notFound;
71 switch (component->source()->type()) {
72 case MediaStreamSource::TypeAudio:
73 pos = m_audioComponents.find(component);
74 if (pos != notFound)
75 m_audioComponents.remove(pos);
76 break;
77 case MediaStreamSource::TypeVideo:
78 pos = m_videoComponents.find(component);
79 if (pos != notFound)
80 m_videoComponents.remove(pos);
81 break;
82 }
83 }
84
85 void MediaStreamDescriptor::addRemoteTrack(MediaStreamComponent* component)
86 {
87 if (m_client)
88 m_client->addRemoteTrack(component);
89 else
90 addComponent(component);
91 }
92
93 void MediaStreamDescriptor::removeRemoteTrack(MediaStreamComponent* component)
94 {
95 if (m_client)
96 m_client->removeRemoteTrack(component);
97 else
98 removeComponent(component);
99 }
100
101 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream SourceVector& audioSources, const MediaStreamSourceVector& videoSources)
102 : m_client(0)
103 , m_id(id)
104 , m_ended(false)
105 {
106 ASSERT(m_id.length());
107 for (size_t i = 0; i < audioSources.size(); i++)
108 m_audioComponents.append(MediaStreamComponent::create(this, audioSources [i]));
109
110 for (size_t i = 0; i < videoSources.size(); i++)
111 m_videoComponents.append(MediaStreamComponent::create(this, videoSources [i]));
112 }
113
114 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream ComponentVector& audioComponents, const MediaStreamComponentVector& videoCompone nts)
115 : m_client(0)
116 , m_id(id)
117 , m_ended(false)
118 {
119 ASSERT(m_id.length());
120 for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin (); iter != audioComponents.end(); ++iter) {
121 (*iter)->setStream(this);
122 m_audioComponents.append((*iter));
123 }
124 for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin (); iter != videoComponents.end(); ++iter) {
125 (*iter)->setStream(this);
126 m_videoComponents.append((*iter));
127 }
128 }
129
130 } // namespace WebCore
131
OLDNEW
« no previous file with comments | « Source/core/platform/mediastream/MediaStreamDescriptor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698