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

Side by Side Diff: media/cdm/external_clear_key_test_helper.cc

Issue 1978123002: Revert of media: Move widevine CDM targets to WidevineCdm folder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « chrome/tools/build/win/FILES.cfg ('k') | media/cdm/ppapi/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/external_clear_key_test_helper.h" 5 #include "media/cdm/external_clear_key_test_helper.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "media/cdm/api/content_decryption_module.h" 11 #include "media/cdm/api/content_decryption_module.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 // INITIALIZE_CDM_MODULE is a macro in api/content_decryption_module.h. 16 // INITIALIZE_CDM_MODULE is a macro in api/content_decryption_module.h.
17 // However, we need to pass it as a string to GetFunctionPointer() once it 17 // However, we need to pass it as a string to GetFunctionPointer() once it
18 // is expanded. 18 // is expanded.
19 #define STRINGIFY(X) #X 19 #define STRINGIFY(X) #X
20 #define MAKE_STRING(X) STRINGIFY(X) 20 #define MAKE_STRING(X) STRINGIFY(X)
21 21
22 const char kClearKeyCdmBaseDirectory[] = "ClearKeyCdm";
23
24 // File name of the External ClearKey CDM on different platforms. 22 // File name of the External ClearKey CDM on different platforms.
25 const base::FilePath::CharType kExternalClearKeyCdmFileName[] = 23 const base::FilePath::CharType kExternalClearKeyCdmFileName[] =
26 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
27 FILE_PATH_LITERAL("libclearkeycdm.dylib"); 25 FILE_PATH_LITERAL("libclearkeycdm.dylib");
28 #elif defined(OS_WIN) 26 #elif defined(OS_WIN)
29 FILE_PATH_LITERAL("clearkeycdm.dll"); 27 FILE_PATH_LITERAL("clearkeycdm.dll");
30 #else // OS_LINUX, etc. 28 #else // OS_LINUX, etc.
31 FILE_PATH_LITERAL("libclearkeycdm.so"); 29 FILE_PATH_LITERAL("libclearkeycdm.so");
32 #endif 30 #endif
33 31
34 ExternalClearKeyTestHelper::ExternalClearKeyTestHelper() { 32 ExternalClearKeyTestHelper::ExternalClearKeyTestHelper() {
35 LoadLibrary(); 33 LoadLibrary();
36 } 34 }
37 35
38 ExternalClearKeyTestHelper::~ExternalClearKeyTestHelper() { 36 ExternalClearKeyTestHelper::~ExternalClearKeyTestHelper() {
39 UnloadLibrary(); 37 UnloadLibrary();
40 } 38 }
41 39
42 void ExternalClearKeyTestHelper::LoadLibrary() { 40 void ExternalClearKeyTestHelper::LoadLibrary() {
43 // Determine the location of the CDM. It is expected to be in the same 41 // Determine the location of the CDM. It is expected to be in the same
44 // directory as the current module. 42 // directory as the current module.
45 base::FilePath library_dir; 43 base::FilePath current_module_dir;
46 ASSERT_TRUE(PathService::Get(base::DIR_MODULE, &library_dir)); 44 ASSERT_TRUE(PathService::Get(base::DIR_MODULE, &current_module_dir));
47 library_dir = library_dir.AppendASCII(kClearKeyCdmBaseDirectory); 45 library_path_ =
48 library_path_ = library_dir.Append(kExternalClearKeyCdmFileName); 46 current_module_dir.Append(base::FilePath(kExternalClearKeyCdmFileName));
49 ASSERT_TRUE(base::PathExists(library_path_)) << library_path_.value(); 47 ASSERT_TRUE(base::PathExists(library_path_)) << library_path_.value();
50 48
51 // Now load the CDM library. 49 // Now load the CDM library.
52 base::NativeLibraryLoadError error; 50 base::NativeLibraryLoadError error;
53 library_.Reset(base::LoadNativeLibrary(library_path_, &error)); 51 library_.Reset(base::LoadNativeLibrary(library_path_, &error));
54 ASSERT_TRUE(library_.is_valid()) << error.ToString(); 52 ASSERT_TRUE(library_.is_valid()) << error.ToString();
55 53
56 // Call INITIALIZE_CDM_MODULE() 54 // Call INITIALIZE_CDM_MODULE()
57 typedef void (*InitializeCdmFunc)(); 55 typedef void (*InitializeCdmFunc)();
58 InitializeCdmFunc initialize_cdm_func = reinterpret_cast<InitializeCdmFunc>( 56 InitializeCdmFunc initialize_cdm_func = reinterpret_cast<InitializeCdmFunc>(
59 library_.GetFunctionPointer(MAKE_STRING(INITIALIZE_CDM_MODULE))); 57 library_.GetFunctionPointer(MAKE_STRING(INITIALIZE_CDM_MODULE)));
60 ASSERT_TRUE(initialize_cdm_func) << "No INITIALIZE_CDM_MODULE in library"; 58 ASSERT_TRUE(initialize_cdm_func) << "No INITIALIZE_CDM_MODULE in library";
61 initialize_cdm_func(); 59 initialize_cdm_func();
62 } 60 }
63 61
64 void ExternalClearKeyTestHelper::UnloadLibrary() { 62 void ExternalClearKeyTestHelper::UnloadLibrary() {
65 // Call DeinitializeCdmModule() 63 // Call DeinitializeCdmModule()
66 typedef void (*DeinitializeCdmFunc)(); 64 typedef void (*DeinitializeCdmFunc)();
67 DeinitializeCdmFunc deinitialize_cdm_func = 65 DeinitializeCdmFunc deinitialize_cdm_func =
68 reinterpret_cast<DeinitializeCdmFunc>( 66 reinterpret_cast<DeinitializeCdmFunc>(
69 library_.GetFunctionPointer("DeinitializeCdmModule")); 67 library_.GetFunctionPointer("DeinitializeCdmModule"));
70 ASSERT_TRUE(deinitialize_cdm_func) << "No DeinitializeCdmModule() in library"; 68 ASSERT_TRUE(deinitialize_cdm_func) << "No DeinitializeCdmModule() in library";
71 deinitialize_cdm_func(); 69 deinitialize_cdm_func();
72 } 70 }
73 71
74 } // namespace media 72 } // namespace media
OLDNEW
« no previous file with comments | « chrome/tools/build/win/FILES.cfg ('k') | media/cdm/ppapi/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698