| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <list> | |
| 6 | |
| 7 #include "base/bind_helpers.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "mojo/public/cpp/application/connect.h" | |
| 10 #include "mojo/services/media/audio/interfaces/audio_server.mojom.h" | |
| 11 #include "mojo/services/media/audio/interfaces/audio_track.mojom.h" | |
| 12 #include "services/media/factory_service/audio_track_controller.h" | |
| 13 #include "services/media/framework_mojo/mojo_type_conversions.h" | |
| 14 | |
| 15 namespace mojo { | |
| 16 namespace media { | |
| 17 | |
| 18 AudioTrackController::AudioTrackController(const String& url, Shell* shell) { | |
| 19 // TODO(dalesat): Handle connection errors. | |
| 20 DCHECK(shell); | |
| 21 | |
| 22 AudioServerPtr audio_server; | |
| 23 ConnectToService(shell, url, GetProxy(&audio_server)); | |
| 24 audio_server->CreateTrack(GetProxy(&audio_track_)); | |
| 25 } | |
| 26 | |
| 27 AudioTrackController::~AudioTrackController() {} | |
| 28 | |
| 29 void AudioTrackController::GetSupportedMediaTypes( | |
| 30 const GetSupportedMediaTypesCallback& callback) { | |
| 31 // Query the track's format capabilities. | |
| 32 audio_track_->Describe([this, callback](AudioTrackDescriptorPtr descriptor) { | |
| 33 callback(descriptor->supported_media_types.To<std::unique_ptr< | |
| 34 std::vector<std::unique_ptr<media::StreamTypeSet>>>>()); | |
| 35 }); | |
| 36 } | |
| 37 | |
| 38 void AudioTrackController::Configure( | |
| 39 const std::unique_ptr<StreamType>& stream_type, | |
| 40 const ConfigureCallback& callback) { | |
| 41 AudioTrackConfigurationPtr config = AudioTrackConfiguration::New(); | |
| 42 config->media_type = MediaType::From(stream_type); | |
| 43 | |
| 44 MediaConsumerPtr consumer; | |
| 45 audio_track_->Configure(config.Pass(), GetProxy(&consumer)); | |
| 46 | |
| 47 callback(consumer.Pass()); | |
| 48 } | |
| 49 | |
| 50 void AudioTrackController::GetTimelineControlSite( | |
| 51 InterfaceRequest<MediaTimelineControlSite> req) { | |
| 52 audio_track_->GetTimelineControlSite(req.Pass()); | |
| 53 } | |
| 54 | |
| 55 } // namespace media | |
| 56 } // namespace mojo | |
| OLD | NEW |