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

Unified Diff: media/mojo/services/mojo_media_application.cc

Issue 840473002: media: Support creation and SetCdm() for mojo based CDM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: media/mojo/services/mojo_media_application.cc
diff --git a/media/mojo/services/mojo_media_application.cc b/media/mojo/services/mojo_media_application.cc
index a6b0b52a110bf919014cdd1e2ee44c90b163a015..a9b4d3f89226e4d910ec0adc4a08f8851bea03e8 100644
--- a/media/mojo/services/mojo_media_application.cc
+++ b/media/mojo/services/mojo_media_application.cc
@@ -4,6 +4,8 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "media/mojo/services/mojo_cdm_factory_service.h"
+#include "media/mojo/services/mojo_cdm_service_context.h"
#include "media/mojo/services/mojo_renderer_service.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/public/c/system/main.h"
@@ -14,41 +16,61 @@
namespace media {
+static void EnableLoggingFromArgs(const std::vector<std::string>& args) {
xhwang 2015/01/05 23:52:38 This is moved from Initialize().
+ base::CommandLine::StringVector command_line_args;
+#if defined(OS_WIN)
+ for (const auto& arg : args)
+ command_line_args.push_back(base::UTF8ToUTF16(arg));
+#elif defined(OS_POSIX)
+ command_line_args = args;
+#endif
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->InitFromArgv(command_line_args);
+
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
+ logging::InitLogging(settings);
+ // Display process ID, thread ID and timestamp in logs.
+ logging::SetLogItems(true, true, true, false);
+}
+
+// mojo:media app that provides multiple media services.
class MojoMediaApplication
: public mojo::ApplicationDelegate,
+ public mojo::InterfaceFactory<mojo::ContentDecryptionModuleFactory>,
public mojo::InterfaceFactory<mojo::MediaRenderer> {
public:
// mojo::ApplicationDelegate implementation.
void Initialize(mojo::ApplicationImpl* app) override {
- base::CommandLine::StringVector command_line_args;
-#if defined(OS_WIN)
- for (const auto& arg : app->args())
- command_line_args.push_back(base::UTF8ToUTF16(arg));
-#elif defined(OS_POSIX)
- command_line_args = app->args();
-#endif
-
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- command_line->InitFromArgv(command_line_args);
-
- logging::LoggingSettings settings;
- settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
- logging::InitLogging(settings);
- // Display process ID, thread ID and timestamp in logs.
- logging::SetLogItems(true, true, true, false);
+ EnableLoggingFromArgs(app->args());
}
bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) override {
- connection->AddService(this);
+ mojo::ApplicationConnection* connection) final {
+ connection->AddService<mojo::ContentDecryptionModuleFactory>(this);
+ connection->AddService<mojo::MediaRenderer>(this);
return true;
}
// mojo::InterfaceFactory<mojo::MediaRenderer> implementation.
void Create(mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<mojo::MediaRenderer> request) override {
- mojo::BindToRequest(new MojoRendererService(), &request);
+ mojo::InterfaceRequest<mojo::MediaRenderer> request) final {
+ mojo::BindToRequest(new MojoRendererService(&cdm_service_context_),
+ &request);
}
+
+ // mojo::InterfaceFactory<mojo::ContentDecryptionModuleFactory>
+ // implementation.
+ void Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::ContentDecryptionModuleFactory>
+ request) final {
+ mojo::WeakBindToRequest(new MojoCdmFactoryService(&cdm_service_context_),
+ &request);
+ }
+
+ private:
+ MojoCdmServiceContext cdm_service_context_;
};
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698