| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "media/cdm/cdm_adapter_factory.h" | 5 #include "media/cdm/cdm_adapter_factory.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "media/base/cdm_factory.h" | 13 #include "media/base/cdm_factory.h" |
| 14 #include "media/base/key_systems.h" | 14 #include "media/base/key_systems.h" |
| 15 #include "media/cdm/cdm_adapter.h" | 15 #include "media/cdm/cdm_adapter.h" |
| 16 #include "media/cdm/cdm_paths.h" | 16 #include "media/cdm/cdm_paths.h" |
| 17 #include "third_party/widevine/cdm/widevine_cdm_common.h" | 17 |
| 18 #if defined(OS_MACOSX) |
| 19 #include "base/mac/bundle_locations.h" |
| 20 #endif |
| 21 |
| 22 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 18 | 23 |
| 19 namespace media { | 24 namespace media { |
| 20 | 25 |
| 21 CdmAdapterFactory::CdmAdapterFactory( | 26 CdmAdapterFactory::CdmAdapterFactory( |
| 22 CdmAllocator::CreationCB allocator_creation_cb) | 27 CdmAllocator::CreationCB allocator_creation_cb) |
| 23 : allocator_creation_cb_(std::move(allocator_creation_cb)) { | 28 : allocator_creation_cb_(std::move(allocator_creation_cb)) { |
| 24 DCHECK(allocator_creation_cb_); | 29 DCHECK(allocator_creation_cb_); |
| 25 } | 30 } |
| 26 | 31 |
| 27 CdmAdapterFactory::~CdmAdapterFactory() {} | 32 CdmAdapterFactory::~CdmAdapterFactory() {} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 base::FilePath cdm_path; | 52 base::FilePath cdm_path; |
| 48 | 53 |
| 49 #if defined(WIDEVINE_CDM_AVAILABLE) | 54 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 50 // TODO(xhwang): Remove key-system-specific logic here. We should have the | 55 // TODO(xhwang): Remove key-system-specific logic here. We should have the |
| 51 // CDM path forwarded from the browser already. See http://crbug.com/510604 | 56 // CDM path forwarded from the browser already. See http://crbug.com/510604 |
| 52 if (key_system == kWidevineKeySystem) { | 57 if (key_system == kWidevineKeySystem) { |
| 53 // Build the library path for Widevine CDM. | 58 // Build the library path for Widevine CDM. |
| 54 // TODO(xhwang): We should have the CDM path forwarded from the browser | 59 // TODO(xhwang): We should have the CDM path forwarded from the browser |
| 55 // already. See http://crbug.com/510604 | 60 // already. See http://crbug.com/510604 |
| 56 base::FilePath cdm_base_path; | 61 base::FilePath cdm_base_path; |
| 62 |
| 63 #if defined(OS_MACOSX) |
| 64 base::FilePath framework_bundle_path = base::mac::FrameworkBundlePath(); |
| 65 cdm_base_path = framework_bundle_path.Append("Libraries"); |
| 66 #else |
| 57 base::PathService::Get(base::DIR_MODULE, &cdm_base_path); | 67 base::PathService::Get(base::DIR_MODULE, &cdm_base_path); |
| 68 #endif |
| 69 |
| 58 cdm_base_path = cdm_base_path.Append( | 70 cdm_base_path = cdm_base_path.Append( |
| 59 GetPlatformSpecificDirectory(kWidevineCdmBaseDirectory)); | 71 GetPlatformSpecificDirectory(kWidevineCdmBaseDirectory)); |
| 60 cdm_path = cdm_base_path.AppendASCII( | 72 cdm_path = cdm_base_path.AppendASCII( |
| 61 base::GetNativeLibraryName(kWidevineCdmLibraryName)); | 73 base::GetNativeLibraryName(kWidevineCdmLibraryName)); |
| 74 DVLOG(1) << "CDM path: " << cdm_path.value(); |
| 62 } | 75 } |
| 63 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 76 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 64 | 77 |
| 65 if (cdm_path.empty()) { | 78 if (cdm_path.empty()) { |
| 66 base::ThreadTaskRunnerHandle::Get()->PostTask( | 79 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 67 FROM_HERE, | 80 FROM_HERE, |
| 68 base::Bind(cdm_created_cb, nullptr, "Unsupported key system.")); | 81 base::Bind(cdm_created_cb, nullptr, "Unsupported key system.")); |
| 69 return; | 82 return; |
| 70 } | 83 } |
| 71 | 84 |
| 72 std::unique_ptr<CdmAllocator> cdm_allocator = allocator_creation_cb_.Run(); | 85 std::unique_ptr<CdmAllocator> cdm_allocator = allocator_creation_cb_.Run(); |
| 73 if (!cdm_allocator) { | 86 if (!cdm_allocator) { |
| 74 base::ThreadTaskRunnerHandle::Get()->PostTask( | 87 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 75 FROM_HERE, | 88 FROM_HERE, |
| 76 base::Bind(cdm_created_cb, nullptr, "CDM allocator creation failed.")); | 89 base::Bind(cdm_created_cb, nullptr, "CDM allocator creation failed.")); |
| 77 return; | 90 return; |
| 78 } | 91 } |
| 79 | 92 |
| 80 // TODO(xhwang): Hook up auxiliary services, e.g. File IO, output protection, | 93 // TODO(xhwang): Hook up auxiliary services, e.g. File IO, output protection, |
| 81 // and platform verification. | 94 // and platform verification. |
| 82 CdmAdapter::Create(key_system, cdm_path, cdm_config, std::move(cdm_allocator), | 95 CdmAdapter::Create(key_system, cdm_path, cdm_config, std::move(cdm_allocator), |
| 83 CreateCdmFileIOCB(), session_message_cb, session_closed_cb, | 96 CreateCdmFileIOCB(), session_message_cb, session_closed_cb, |
| 84 session_keys_change_cb, session_expiration_update_cb, | 97 session_keys_change_cb, session_expiration_update_cb, |
| 85 cdm_created_cb); | 98 cdm_created_cb); |
| 86 } | 99 } |
| 87 | 100 |
| 88 } // namespace media | 101 } // namespace media |
| OLD | NEW |