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

Side by Side Diff: content/renderer/media/media_interface_provider.cc

Issue 2684103005: Allow media track switching. (Closed)
Patch Set: Added a LayoutTest for media track switching Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_interface_provider.h" 5 #include "content/renderer/media/media_interface_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 10 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
11 #include "media/mojo/interfaces/renderer.mojom.h" 11 #include "media/mojo/interfaces/renderer.mojom.h"
12 #include "mojo/public/cpp/bindings/interface_request.h" 12 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "services/service_manager/public/cpp/interface_provider.h" 13 #include "services/service_manager/public/cpp/interface_provider.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 MediaInterfaceProvider::MediaInterfaceProvider( 17 MediaInterfaceProvider::MediaInterfaceProvider(
18 service_manager::InterfaceProvider* remote_interfaces) 18 service_manager::InterfaceProvider* remote_interfaces)
19 : remote_interfaces_(remote_interfaces) {} 19 : remote_interfaces_(remote_interfaces), weak_factory_(this) {
20 task_runner_ = base::ThreadTaskRunnerHandle::Get();
21 weak_this_ = weak_factory_.GetWeakPtr();
22 }
20 23
21 MediaInterfaceProvider::~MediaInterfaceProvider() { 24 MediaInterfaceProvider::~MediaInterfaceProvider() {
22 DCHECK(thread_checker_.CalledOnValidThread()); 25 DCHECK(thread_checker_.CalledOnValidThread());
23 } 26 }
24 27
25 void MediaInterfaceProvider::GetInterface(const std::string& interface_name, 28 void MediaInterfaceProvider::GetInterface(const std::string& interface_name,
26 mojo::ScopedMessagePipeHandle pipe) { 29 mojo::ScopedMessagePipeHandle pipe) {
27 DVLOG(1) << __func__; 30 DVLOG(1) << __func__;
31 if (!task_runner_->BelongsToCurrentThread()) {
32 task_runner_->PostTask(
33 FROM_HERE, base::Bind(&MediaInterfaceProvider::GetInterface, weak_this_,
34 interface_name, base::Passed(&pipe)));
35 return;
36 }
xhwang 2017/03/27 19:13:53 nit: empty line
servolk 2017/03/27 22:34:12 Done.
28 DCHECK(thread_checker_.CalledOnValidThread()); 37 DCHECK(thread_checker_.CalledOnValidThread());
29 38
30 if (interface_name == media::mojom::ContentDecryptionModule::Name_) { 39 if (interface_name == media::mojom::ContentDecryptionModule::Name_) {
31 GetMediaInterfaceFactory()->CreateCdm( 40 GetMediaInterfaceFactory()->CreateCdm(
32 mojo::MakeRequest<media::mojom::ContentDecryptionModule>( 41 mojo::MakeRequest<media::mojom::ContentDecryptionModule>(
33 std::move(pipe))); 42 std::move(pipe)));
34 } else if (interface_name == media::mojom::Renderer::Name_) { 43 } else if (interface_name == media::mojom::Renderer::Name_) {
35 GetMediaInterfaceFactory()->CreateRenderer( 44 GetMediaInterfaceFactory()->CreateRenderer(
36 std::string(), 45 std::string(),
37 mojo::MakeRequest<media::mojom::Renderer>(std::move(pipe))); 46 mojo::MakeRequest<media::mojom::Renderer>(std::move(pipe)));
(...skipping 23 matching lines...) Expand all
61 } 70 }
62 71
63 void MediaInterfaceProvider::OnConnectionError() { 72 void MediaInterfaceProvider::OnConnectionError() {
64 DVLOG(1) << __func__; 73 DVLOG(1) << __func__;
65 DCHECK(thread_checker_.CalledOnValidThread()); 74 DCHECK(thread_checker_.CalledOnValidThread());
66 75
67 media_interface_factory_.reset(); 76 media_interface_factory_.reset();
68 } 77 }
69 78
70 } // namespace content 79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698