| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #include "core/platform/mediastream/chromium/MediaStreamCenterChromium.h" | 33 #include "core/platform/mediastream/chromium/MediaStreamCenterChromium.h" |
| 34 | 34 |
| 35 #include "core/platform/mediastream/MediaStreamDescriptor.h" | 35 #include "core/platform/mediastream/MediaStreamDescriptor.h" |
| 36 #include "core/platform/mediastream/MediaStreamSourcesQueryClient.h" | 36 #include "core/platform/mediastream/MediaStreamSourcesQueryClient.h" |
| 37 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
| 38 #include "public/platform/WebMediaStream.h" | 38 #include "public/platform/WebMediaStream.h" |
| 39 #include "public/platform/WebMediaStreamCenter.h" | 39 #include "public/platform/WebMediaStreamCenter.h" |
| 40 #include "public/platform/WebMediaStreamSourcesRequest.h" | 40 #include "public/platform/WebMediaStreamSourcesRequest.h" |
| 41 #include "public/platform/WebMediaStreamTrack.h" | 41 #include "public/platform/WebMediaStreamTrack.h" |
| 42 #include <wtf/MainThread.h> | 42 #include "wtf/MainThread.h" |
| 43 #include <wtf/PassOwnPtr.h> | 43 #include "wtf/PassOwnPtr.h" |
| 44 | 44 |
| 45 namespace WebCore { | 45 namespace WebCore { |
| 46 | 46 |
| 47 MediaStreamCenter& MediaStreamCenter::instance() | 47 MediaStreamCenter& MediaStreamCenter::instance() |
| 48 { | 48 { |
| 49 ASSERT(isMainThread()); | 49 ASSERT(isMainThread()); |
| 50 DEFINE_STATIC_LOCAL(MediaStreamCenterChromium, center, ()); | 50 DEFINE_STATIC_LOCAL(MediaStreamCenterChromium, center, ()); |
| 51 return center; | 51 return center; |
| 52 } | 52 } |
| 53 | 53 |
| 54 MediaStreamCenterChromium::MediaStreamCenterChromium() | 54 MediaStreamCenterChromium::MediaStreamCenterChromium() |
| 55 : m_private(adoptPtr(WebKit::Platform::current()->createMediaStreamCenter(th
is))) | 55 : m_private(adoptPtr(WebKit::Platform::current()->createMediaStreamCenter(th
is))) |
| 56 { | 56 { |
| 57 } | 57 } |
| 58 | 58 |
| 59 MediaStreamCenterChromium::~MediaStreamCenterChromium() | 59 MediaStreamCenterChromium::~MediaStreamCenterChromium() |
| 60 { | 60 { |
| 61 } | 61 } |
| 62 | 62 |
| 63 void MediaStreamCenterChromium::queryMediaStreamSources(PassRefPtr<MediaStreamSo
urcesQueryClient> client) | 63 void MediaStreamCenterChromium::queryMediaStreamSources(PassRefPtr<MediaStreamSo
urcesQueryClient> client) |
| 64 { | 64 { |
| 65 if (m_private) | 65 if (m_private) |
| 66 m_private->queryMediaStreamSources(client); | 66 m_private->queryMediaStreamSources(client); |
| 67 else { | 67 else { |
| 68 MediaStreamSourceVector audioSources, videoSources; | 68 MediaStreamSourceVector audioSources, videoSources; |
| 69 client->didCompleteQuery(audioSources, videoSources); | 69 client->didCompleteQuery(audioSources, videoSources); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool MediaStreamCenterChromium::getSourceInfos(const String& url, WebKit::WebVec
tor<WebKit::WebSourceInfo>& sourceInfos) |
| 74 { |
| 75 return m_private && m_private->getSourceInfos(url, sourceInfos); |
| 76 } |
| 77 |
| 73 void MediaStreamCenterChromium::didSetMediaStreamTrackEnabled(MediaStreamDescrip
tor* stream, MediaStreamComponent* component) | 78 void MediaStreamCenterChromium::didSetMediaStreamTrackEnabled(MediaStreamDescrip
tor* stream, MediaStreamComponent* component) |
| 74 { | 79 { |
| 75 if (m_private) { | 80 if (m_private) { |
| 76 if (component->enabled()) | 81 if (component->enabled()) |
| 77 m_private->didEnableMediaStreamTrack(stream, component); | 82 m_private->didEnableMediaStreamTrack(stream, component); |
| 78 else | 83 else |
| 79 m_private->didDisableMediaStreamTrack(stream, component); | 84 m_private->didDisableMediaStreamTrack(stream, component); |
| 80 } | 85 } |
| 81 } | 86 } |
| 82 | 87 |
| 83 bool MediaStreamCenterChromium::didAddMediaStreamTrack(MediaStreamDescriptor* st
ream, MediaStreamComponent* component) | 88 bool MediaStreamCenterChromium::didAddMediaStreamTrack(MediaStreamDescriptor* st
ream, MediaStreamComponent* component) |
| 84 { | 89 { |
| 85 return m_private ? m_private->didAddMediaStreamTrack(stream, component) : fa
lse; | 90 return m_private && m_private->didAddMediaStreamTrack(stream, component); |
| 86 } | 91 } |
| 87 | 92 |
| 88 bool MediaStreamCenterChromium::didRemoveMediaStreamTrack(MediaStreamDescriptor*
stream, MediaStreamComponent* component) | 93 bool MediaStreamCenterChromium::didRemoveMediaStreamTrack(MediaStreamDescriptor*
stream, MediaStreamComponent* component) |
| 89 { | 94 { |
| 90 return m_private ? m_private->didRemoveMediaStreamTrack(stream, component) :
false; | 95 return m_private && m_private->didRemoveMediaStreamTrack(stream, component); |
| 91 } | 96 } |
| 92 | 97 |
| 93 void MediaStreamCenterChromium::didStopLocalMediaStream(MediaStreamDescriptor* s
tream) | 98 void MediaStreamCenterChromium::didStopLocalMediaStream(MediaStreamDescriptor* s
tream) |
| 94 { | 99 { |
| 95 if (m_private) { | 100 if (m_private) { |
| 96 m_private->didStopLocalMediaStream(stream); | 101 m_private->didStopLocalMediaStream(stream); |
| 97 for (unsigned i = 0; i < stream->numberOfAudioComponents(); i++) | 102 for (unsigned i = 0; i < stream->numberOfAudioComponents(); i++) |
| 98 stream->audioComponent(i)->source()->setReadyState(MediaStreamSource
::ReadyStateEnded); | 103 stream->audioComponent(i)->source()->setReadyState(MediaStreamSource
::ReadyStateEnded); |
| 99 for (unsigned i = 0; i < stream->numberOfVideoComponents(); i++) | 104 for (unsigned i = 0; i < stream->numberOfVideoComponents(); i++) |
| 100 stream->videoComponent(i)->source()->setReadyState(MediaStreamSource
::ReadyStateEnded); | 105 stream->videoComponent(i)->source()->setReadyState(MediaStreamSource
::ReadyStateEnded); |
| 101 } | 106 } |
| 102 } | 107 } |
| 103 | 108 |
| 104 void MediaStreamCenterChromium::didCreateMediaStream(MediaStreamDescriptor* stre
am) | 109 void MediaStreamCenterChromium::didCreateMediaStream(MediaStreamDescriptor* stre
am) |
| 105 { | 110 { |
| 106 if (m_private) { | 111 if (m_private) { |
| 107 WebKit::WebMediaStream webStream(stream); | 112 WebKit::WebMediaStream webStream(stream); |
| 108 m_private->didCreateMediaStream(webStream); | 113 m_private->didCreateMediaStream(webStream); |
| 109 } | 114 } |
| 110 } | 115 } |
| 111 | 116 |
| 112 void MediaStreamCenterChromium::stopLocalMediaStream(const WebKit::WebMediaStrea
m& stream) | 117 void MediaStreamCenterChromium::stopLocalMediaStream(const WebKit::WebMediaStrea
m& stream) |
| 113 { | 118 { |
| 114 endLocalMediaStream(stream); | 119 endLocalMediaStream(stream); |
| 115 } | 120 } |
| 116 | 121 |
| 117 } // namespace WebCore | 122 } // namespace WebCore |
| OLD | NEW |