OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/content_decryptor_delegate.h" | 5 #include "content/renderer/pepper/content_decryptor_delegate.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/safe_numerics.h" | 10 #include "base/numerics/safe_conversions.h" |
11 #include "content/renderer/pepper/ppb_buffer_impl.h" | 11 #include "content/renderer/pepper/ppb_buffer_impl.h" |
12 #include "media/base/audio_buffer.h" | 12 #include "media/base/audio_buffer.h" |
13 #include "media/base/audio_decoder_config.h" | 13 #include "media/base/audio_decoder_config.h" |
14 #include "media/base/bind_to_current_loop.h" | 14 #include "media/base/bind_to_current_loop.h" |
15 #include "media/base/channel_layout.h" | 15 #include "media/base/channel_layout.h" |
16 #include "media/base/data_buffer.h" | 16 #include "media/base/data_buffer.h" |
17 #include "media/base/decoder_buffer.h" | 17 #include "media/base/decoder_buffer.h" |
18 #include "media/base/decrypt_config.h" | 18 #include "media/base/decrypt_config.h" |
19 #include "media/base/video_decoder_config.h" | 19 #include "media/base/video_decoder_config.h" |
20 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 memcpy(×tamp, cur, sizeof(timestamp)); | 991 memcpy(×tamp, cur, sizeof(timestamp)); |
992 cur += sizeof(timestamp); | 992 cur += sizeof(timestamp); |
993 bytes_left -= sizeof(timestamp); | 993 bytes_left -= sizeof(timestamp); |
994 | 994 |
995 memcpy(&frame_size, cur, sizeof(frame_size)); | 995 memcpy(&frame_size, cur, sizeof(frame_size)); |
996 cur += sizeof(frame_size); | 996 cur += sizeof(frame_size); |
997 bytes_left -= sizeof(frame_size); | 997 bytes_left -= sizeof(frame_size); |
998 | 998 |
999 // We should *not* have empty frames in the list. | 999 // We should *not* have empty frames in the list. |
1000 if (frame_size <= 0 || | 1000 if (frame_size <= 0 || |
1001 bytes_left < base::checked_numeric_cast<size_t>(frame_size)) { | 1001 bytes_left < base::checked_cast<size_t>(frame_size)) { |
1002 return false; | 1002 return false; |
1003 } | 1003 } |
1004 | 1004 |
1005 // Setup channel pointers. AudioBuffer::CopyFrom() will only use the first | 1005 // Setup channel pointers. AudioBuffer::CopyFrom() will only use the first |
1006 // one in the case of interleaved data. | 1006 // one in the case of interleaved data. |
1007 const int size_per_channel = frame_size / audio_channel_count_; | 1007 const int size_per_channel = frame_size / audio_channel_count_; |
1008 for (int i = 0; i < audio_channel_count_; ++i) | 1008 for (int i = 0; i < audio_channel_count_; ++i) |
1009 channel_ptrs[i] = cur + i * size_per_channel; | 1009 channel_ptrs[i] = cur + i * size_per_channel; |
1010 | 1010 |
1011 const int frame_count = frame_size / audio_bytes_per_frame; | 1011 const int frame_count = frame_size / audio_bytes_per_frame; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 const media::Decryptor::AudioBuffers empty_frames; | 1046 const media::Decryptor::AudioBuffers empty_frames; |
1047 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, | 1047 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, |
1048 empty_frames); | 1048 empty_frames); |
1049 } | 1049 } |
1050 | 1050 |
1051 if (!video_decode_cb_.is_null()) | 1051 if (!video_decode_cb_.is_null()) |
1052 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1052 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
1053 } | 1053 } |
1054 | 1054 |
1055 } // namespace content | 1055 } // namespace content |
OLD | NEW |