Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <math.h> | 5 #include <math.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 dict.Set(pp::Var("name"), pp::Var("supportedProfiles")); | 287 dict.Set(pp::Var("name"), pp::Var("supportedProfiles")); |
| 288 pp::VarArray js_profiles; | 288 pp::VarArray js_profiles; |
| 289 dict.Set(pp::Var("profiles"), js_profiles); | 289 dict.Set(pp::Var("profiles"), js_profiles); |
| 290 | 290 |
| 291 if (result != PP_OK) { | 291 if (result != PP_OK) { |
| 292 LogError(result, "Cannot get supported profiles"); | 292 LogError(result, "Cannot get supported profiles"); |
| 293 PostMessage(dict); | 293 PostMessage(dict); |
| 294 } | 294 } |
| 295 | 295 |
| 296 int32_t idx = 0; | 296 int32_t idx = 0; |
| 297 for (const PP_VideoProfileDescription& profile : profiles) | 297 for (int32_t i = 0; i < profiles.size(); i++) { |
| 298 const PP_VideoProfileDescription& profile = profiles[i]; | |
| 298 js_profiles.Set(idx++, pp::Var(VideoProfileToString(profile.profile))); | 299 js_profiles.Set(idx++, pp::Var(VideoProfileToString(profile.profile))); |
| 300 } | |
| 299 PostMessage(dict); | 301 PostMessage(dict); |
| 300 } | 302 } |
| 301 | 303 |
| 302 void VideoEncoderInstance::StartEncoder() { | 304 void VideoEncoderInstance::StartEncoder() { |
| 303 video_encoder_ = pp::VideoEncoder(this); | 305 video_encoder_ = pp::VideoEncoder(this); |
| 304 | 306 |
| 305 int32_t error = video_encoder_.Initialize( | 307 int32_t error = video_encoder_.Initialize( |
| 306 frame_format_, frame_size_, video_profile_, 2000000, | 308 frame_format_, frame_size_, video_profile_, 2000000, |
| 307 PP_HARDWAREACCELERATION_WITHFALLBACK, | 309 PP_HARDWAREACCELERATION_WITHFALLBACK, |
| 308 callback_factory_.NewCallback( | 310 callback_factory_.NewCallback( |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 | 557 |
| 556 void VideoEncoderInstance::LogError(int32_t error, const std::string& message) { | 558 void VideoEncoderInstance::LogError(int32_t error, const std::string& message) { |
| 557 std::string msg("Error: "); | 559 std::string msg("Error: "); |
| 558 msg.append(pp::Var(error).DebugString()); | 560 msg.append(pp::Var(error).DebugString()); |
| 559 msg.append(" : "); | 561 msg.append(" : "); |
| 560 msg.append(message); | 562 msg.append(message); |
| 561 LogToConsole(PP_LOGLEVEL_ERROR, pp::Var(msg)); | 563 LogToConsole(PP_LOGLEVEL_ERROR, pp::Var(msg)); |
| 562 } | 564 } |
| 563 | 565 |
| 564 void VideoEncoderInstance::Log(const std::string& message) { | 566 void VideoEncoderInstance::Log(const std::string& message) { |
| 565 LogToConsole(PP_LOGLEVEL_LOG, pp::Var(message)); | 567 LogToConsole(PP_LOGLEVEL_LOG, pp::Var(message)); |
|
binji
2015/03/31 17:41:19
It would be nice to have these errors log to the h
llandwerlin-old
2015/04/02 09:59:01
Done.
| |
| 566 } | 568 } |
| 567 | 569 |
| 568 pp::Instance* VideoEncoderModule::CreateInstance(PP_Instance instance) { | 570 pp::Instance* VideoEncoderModule::CreateInstance(PP_Instance instance) { |
| 569 return new VideoEncoderInstance(instance, this); | 571 return new VideoEncoderInstance(instance, this); |
| 570 } | 572 } |
| 571 | 573 |
| 572 } // anonymous namespace | 574 } // anonymous namespace |
| 573 | 575 |
| 574 namespace pp { | 576 namespace pp { |
| 575 // Factory function for your specialization of the Module object. | 577 // Factory function for your specialization of the Module object. |
| 576 Module* CreateModule() { | 578 Module* CreateModule() { |
| 577 return new VideoEncoderModule(); | 579 return new VideoEncoderModule(); |
| 578 } | 580 } |
| 579 } // namespace pp | 581 } // namespace pp |
| OLD | NEW |