| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ppapi/clear_key_cdm.h" | 5 #include "media/cdm/ppapi/clear_key_cdm.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "media/base/decoder_buffer.h" | 16 #include "media/base/decoder_buffer.h" |
| 17 #include "media/base/decrypt_config.h" | 17 #include "media/base/decrypt_config.h" |
| 18 #include "media/cdm/ppapi/cdm_video_decoder.h" | 18 #include "media/cdm/ppapi/cdm_video_decoder.h" |
| 19 | 19 |
| 20 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 20 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
| 21 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
| 22 static const int64 kNoTimestamp = kint64min; | 22 const int64 kNoTimestamp = kint64min; |
| 23 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 23 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 24 | 24 |
| 25 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 25 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
| 26 #include "base/at_exit.h" | 26 #include "base/at_exit.h" |
| 27 #include "base/files/file_path.h" | 27 #include "base/files/file_path.h" |
| 28 #include "base/path_service.h" | 28 #include "base/path_service.h" |
| 29 #include "media/base/media.h" | 29 #include "media/base/media.h" |
| 30 #include "media/cdm/ppapi/ffmpeg_cdm_audio_decoder.h" | 30 #include "media/cdm/ppapi/ffmpeg_cdm_audio_decoder.h" |
| 31 #include "media/cdm/ppapi/ffmpeg_cdm_video_decoder.h" | 31 #include "media/cdm/ppapi/ffmpeg_cdm_video_decoder.h" |
| 32 | 32 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 52 static bool InitializeFFmpegLibraries() { | 52 static bool InitializeFFmpegLibraries() { |
| 53 base::FilePath file_path; | 53 base::FilePath file_path; |
| 54 CHECK(PathService::Get(base::DIR_MODULE, &file_path)); | 54 CHECK(PathService::Get(base::DIR_MODULE, &file_path)); |
| 55 CHECK(media::InitializeMediaLibrary(file_path)); | 55 CHECK(media::InitializeMediaLibrary(file_path)); |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 static bool g_ffmpeg_lib_initialized = InitializeFFmpegLibraries(); | 59 static bool g_ffmpeg_lib_initialized = InitializeFFmpegLibraries(); |
| 60 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 60 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
| 61 | 61 |
| 62 static const char kClearKeyCdmVersion[] = "0.1.0.1"; | 62 const char kClearKeyCdmVersion[] = "0.1.0.1"; |
| 63 static const char kExternalClearKey[] = "org.chromium.externalclearkey"; | 63 const int64 kSecondsPerMinute = 60; |
| 64 static const int64 kSecondsPerMinute = 60; | 64 const int64 kMsPerSecond = 1000; |
| 65 static const int64 kMsPerSecond = 1000; | 65 const int64 kInitialTimerDelayMs = 200; |
| 66 static const int64 kInitialTimerDelayMs = 200; | 66 const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond; |
| 67 static const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond; | |
| 68 // Heart beat message header. If a key message starts with |kHeartBeatHeader|, | 67 // Heart beat message header. If a key message starts with |kHeartBeatHeader|, |
| 69 // it's a heart beat message. Otherwise, it's a key request. | 68 // it's a heart beat message. Otherwise, it's a key request. |
| 70 static const char kHeartBeatHeader[] = "HEARTBEAT"; | 69 const char kHeartBeatHeader[] = "HEARTBEAT"; |
| 71 | 70 |
| 72 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is | 71 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is |
| 73 // empty, an empty (end-of-stream) media::DecoderBuffer is returned. | 72 // empty, an empty (end-of-stream) media::DecoderBuffer is returned. |
| 74 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( | 73 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( |
| 75 const cdm::InputBuffer& input_buffer) { | 74 const cdm::InputBuffer& input_buffer) { |
| 76 if (!input_buffer.data) { | 75 if (!input_buffer.data) { |
| 77 DCHECK_EQ(input_buffer.data_size, 0); | 76 DCHECK_EQ(input_buffer.data_size, 0); |
| 78 return media::DecoderBuffer::CreateEOSBuffer(); | 77 return media::DecoderBuffer::CreateEOSBuffer(); |
| 79 } | 78 } |
| 80 | 79 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 int samples_generated = GenerateFakeAudioFramesFromDuration( | 548 int samples_generated = GenerateFakeAudioFramesFromDuration( |
| 550 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), | 549 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), |
| 551 audio_frames); | 550 audio_frames); |
| 552 total_samples_generated_ += samples_generated; | 551 total_samples_generated_ += samples_generated; |
| 553 | 552 |
| 554 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; | 553 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; |
| 555 } | 554 } |
| 556 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 555 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 557 | 556 |
| 558 } // namespace media | 557 } // namespace media |
| OLD | NEW |