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

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

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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Ericsson AB. All rights reserved. 2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. 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 14 matching lines...) Expand all
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #ifndef MediaStreamDescriptor_h 32 #ifndef MediaStreamDescriptor_h
33 #define MediaStreamDescriptor_h 33 #define MediaStreamDescriptor_h
34 34
35 #include "core/platform/UUID.h"
36 #include "core/platform/mediastream/MediaStreamComponent.h" 35 #include "core/platform/mediastream/MediaStreamComponent.h"
36 #include "core/platform/mediastream/MediaStreamSource.h"
37 #include <wtf/RefCounted.h> 37 #include <wtf/RefCounted.h>
38 #include <wtf/Vector.h> 38 #include <wtf/Vector.h>
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 class MediaStreamDescriptorClient { 42 class MediaStreamDescriptorClient {
43 public: 43 public:
44 virtual ~MediaStreamDescriptorClient() { } 44 virtual ~MediaStreamDescriptorClient() { }
45 45
46 virtual void trackEnded() = 0; 46 virtual void trackEnded() = 0;
47 virtual void streamEnded() = 0; 47 virtual void streamEnded() = 0;
48 virtual void addRemoteTrack(MediaStreamComponent*) = 0; 48 virtual void addRemoteTrack(MediaStreamComponent*) = 0;
49 virtual void removeRemoteTrack(MediaStreamComponent*) = 0; 49 virtual void removeRemoteTrack(MediaStreamComponent*) = 0;
50 }; 50 };
51 51
52 class MediaStreamDescriptor : public RefCounted<MediaStreamDescriptor> { 52 class MediaStreamDescriptor : public RefCounted<MediaStreamDescriptor> {
53 public: 53 public:
54 class ExtraData : public RefCounted<ExtraData> { 54 class ExtraData : public RefCounted<ExtraData> {
55 public: 55 public:
56 virtual ~ExtraData() { } 56 virtual ~ExtraData() { }
57 }; 57 };
58 58
59 static PassRefPtr<MediaStreamDescriptor> create(const MediaStreamSourceVecto r& audioSources, const MediaStreamSourceVector& videoSources) 59 static PassRefPtr<MediaStreamDescriptor> create(const MediaStreamSourceVecto r& audioSources, const MediaStreamSourceVector& videoSources);
60 {
61 return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), a udioSources, videoSources));
62 }
63 60
64 static PassRefPtr<MediaStreamDescriptor> create(const String& id, const Medi aStreamComponentVector& audioComponents, const MediaStreamComponentVector& video Components) 61 static PassRefPtr<MediaStreamDescriptor> create(const String& id, const Medi aStreamComponentVector& audioComponents, const MediaStreamComponentVector& video Components);
65 {
66 return adoptRef(new MediaStreamDescriptor(id, audioComponents, videoComp onents));
67 }
68 62
69 MediaStreamDescriptorClient* client() const { return m_client; } 63 MediaStreamDescriptorClient* client() const { return m_client; }
70 void setClient(MediaStreamDescriptorClient* client) { m_client = client; } 64 void setClient(MediaStreamDescriptorClient* client) { m_client = client; }
71 65
72 String id() const { return m_id; } 66 String id() const { return m_id; }
73 67
74 unsigned numberOfAudioComponents() const { return m_audioComponents.size(); } 68 unsigned numberOfAudioComponents() const { return m_audioComponents.size(); }
75 MediaStreamComponent* audioComponent(unsigned index) const { return m_audioC omponents[index].get(); } 69 MediaStreamComponent* audioComponent(unsigned index) const { return m_audioC omponents[index].get(); }
76 70
77 unsigned numberOfVideoComponents() const { return m_videoComponents.size(); } 71 unsigned numberOfVideoComponents() const { return m_videoComponents.size(); }
78 MediaStreamComponent* videoComponent(unsigned index) const { return m_videoC omponents[index].get(); } 72 MediaStreamComponent* videoComponent(unsigned index) const { return m_videoC omponents[index].get(); }
79 73
80 void addComponent(PassRefPtr<MediaStreamComponent> component) { 74 void addComponent(PassRefPtr<MediaStreamComponent>);
81 switch (component->source()->type()) { 75 void removeComponent(PassRefPtr<MediaStreamComponent>);
82 case MediaStreamSource::TypeAudio:
83 if (m_audioComponents.find(component) == notFound)
84 m_audioComponents.append(component);
85 break;
86 case MediaStreamSource::TypeVideo:
87 if (m_videoComponents.find(component) == notFound)
88 m_videoComponents.append(component);
89 break;
90 }
91 }
92 76
93 void removeComponent(PassRefPtr<MediaStreamComponent> component) { 77 void addRemoteTrack(MediaStreamComponent*);
94 size_t pos = notFound; 78 void removeRemoteTrack(MediaStreamComponent*);
95 switch (component->source()->type()) {
96 case MediaStreamSource::TypeAudio:
97 pos = m_audioComponents.find(component);
98 if (pos != notFound)
99 m_audioComponents.remove(pos);
100 break;
101 case MediaStreamSource::TypeVideo:
102 pos = m_videoComponents.find(component);
103 if (pos != notFound)
104 m_videoComponents.remove(pos);
105 break;
106 }
107 }
108
109 void addRemoteTrack(MediaStreamComponent* component)
110 {
111 if (m_client)
112 m_client->addRemoteTrack(component);
113 else
114 addComponent(component);
115 }
116
117 void removeRemoteTrack(MediaStreamComponent* component)
118 {
119 if (m_client)
120 m_client->removeRemoteTrack(component);
121 else
122 removeComponent(component);
123 }
124 79
125 bool ended() const { return m_ended; } 80 bool ended() const { return m_ended; }
126 void setEnded() { m_ended = true; } 81 void setEnded() { m_ended = true; }
127 82
128 PassRefPtr<ExtraData> extraData() const { return m_extraData; } 83 PassRefPtr<ExtraData> extraData() const { return m_extraData; }
129 void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData ; } 84 void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData ; }
130 85
131 private: 86 private:
132 MediaStreamDescriptor(const String& id, const MediaStreamSourceVector& audio Sources, const MediaStreamSourceVector& videoSources) 87 MediaStreamDescriptor(const String& id, const MediaStreamSourceVector& audio Sources, const MediaStreamSourceVector& videoSources);
133 : m_client(0) 88 MediaStreamDescriptor(const String& id, const MediaStreamComponentVector& au dioComponents, const MediaStreamComponentVector& videoComponents);
134 , m_id(id)
135 , m_ended(false)
136 {
137 ASSERT(m_id.length());
138 for (size_t i = 0; i < audioSources.size(); i++)
139 m_audioComponents.append(MediaStreamComponent::create(this, audioSou rces[i]));
140
141 for (size_t i = 0; i < videoSources.size(); i++)
142 m_videoComponents.append(MediaStreamComponent::create(this, videoSou rces[i]));
143 }
144
145 MediaStreamDescriptor(const String& id, const MediaStreamComponentVector& au dioComponents, const MediaStreamComponentVector& videoComponents)
146 : m_client(0)
147 , m_id(id)
148 , m_ended(false)
149 {
150 ASSERT(m_id.length());
151 for (MediaStreamComponentVector::const_iterator iter = audioComponents.b egin(); iter != audioComponents.end(); ++iter) {
152 (*iter)->setStream(this);
153 m_audioComponents.append((*iter));
154 }
155 for (MediaStreamComponentVector::const_iterator iter = videoComponents.b egin(); iter != videoComponents.end(); ++iter) {
156 (*iter)->setStream(this);
157 m_videoComponents.append((*iter));
158 }
159 }
160 89
161 MediaStreamDescriptorClient* m_client; 90 MediaStreamDescriptorClient* m_client;
162 String m_id; 91 String m_id;
163 Vector<RefPtr<MediaStreamComponent> > m_audioComponents; 92 Vector<RefPtr<MediaStreamComponent> > m_audioComponents;
164 Vector<RefPtr<MediaStreamComponent> > m_videoComponents; 93 Vector<RefPtr<MediaStreamComponent> > m_videoComponents;
165 bool m_ended; 94 bool m_ended;
166 95
167 RefPtr<ExtraData> m_extraData; 96 RefPtr<ExtraData> m_extraData;
168 }; 97 };
169 98
170 typedef Vector<RefPtr<MediaStreamDescriptor> > MediaStreamDescriptorVector; 99 typedef Vector<RefPtr<MediaStreamDescriptor> > MediaStreamDescriptorVector;
171 100
172 } // namespace WebCore 101 } // namespace WebCore
173 102
174 #endif // MediaStreamDescriptor_h 103 #endif // MediaStreamDescriptor_h
OLDNEW
« no previous file with comments | « Source/core/platform/mediastream/MediaStreamComponent.cpp ('k') | Source/core/platform/mediastream/MediaStreamDescriptor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698