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 "media/filters/ffmpeg_demuxer.h" | 5 #include "media/filters/ffmpeg_demuxer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 NOTREACHED() << "Attempted to enqueue packet on a stopped stream"; | 101 NOTREACHED() << "Attempted to enqueue packet on a stopped stream"; |
102 return; | 102 return; |
103 } | 103 } |
104 | 104 |
105 // Convert the packet if there is a bitstream filter. | 105 // Convert the packet if there is a bitstream filter. |
106 if (packet->data && bitstream_converter_enabled_ && | 106 if (packet->data && bitstream_converter_enabled_ && |
107 !bitstream_converter_->ConvertPacket(packet.get())) { | 107 !bitstream_converter_->ConvertPacket(packet.get())) { |
108 LOG(ERROR) << "Format conversion failed."; | 108 LOG(ERROR) << "Format conversion failed."; |
109 } | 109 } |
110 | 110 |
| 111 // Get side data if any. For now, the only type of side_data is VP8 Alpha. We |
| 112 // keep this generic so that other side_data types in the future can be |
| 113 // handled the same way as well. |
| 114 av_packet_split_side_data(packet.get()); |
| 115 int side_data_size = 0; |
| 116 uint8* side_data = av_packet_get_side_data( |
| 117 packet.get(), |
| 118 AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, |
| 119 &side_data_size); |
| 120 |
111 // If a packet is returned by FFmpeg's av_parser_parse2() the packet will | 121 // If a packet is returned by FFmpeg's av_parser_parse2() the packet will |
112 // reference inner memory of FFmpeg. As such we should transfer the packet | 122 // reference inner memory of FFmpeg. As such we should transfer the packet |
113 // into memory we control. | 123 // into memory we control. |
114 scoped_refptr<DecoderBuffer> buffer; | 124 scoped_refptr<DecoderBuffer> buffer; |
115 buffer = DecoderBuffer::CopyFrom(packet->data, packet->size); | 125 if (side_data_size > 0) { |
| 126 buffer = DecoderBuffer::CopyFrom(packet.get()->data, packet.get()->size, |
| 127 side_data, side_data_size); |
| 128 } else { |
| 129 buffer = DecoderBuffer::CopyFrom(packet.get()->data, packet.get()->size); |
| 130 } |
116 | 131 |
117 if ((type() == DemuxerStream::AUDIO && audio_config_.is_encrypted()) || | 132 if ((type() == DemuxerStream::AUDIO && audio_config_.is_encrypted()) || |
118 (type() == DemuxerStream::VIDEO && video_config_.is_encrypted())) { | 133 (type() == DemuxerStream::VIDEO && video_config_.is_encrypted())) { |
119 scoped_ptr<DecryptConfig> config(WebMCreateDecryptConfig( | 134 scoped_ptr<DecryptConfig> config(WebMCreateDecryptConfig( |
120 packet->data, packet->size, | 135 packet->data, packet->size, |
121 reinterpret_cast<const uint8*>(encryption_key_id_.data()), | 136 reinterpret_cast<const uint8*>(encryption_key_id_.data()), |
122 encryption_key_id_.size())); | 137 encryption_key_id_.size())); |
123 if (!config) | 138 if (!config) |
124 LOG(ERROR) << "Creation of DecryptConfig failed."; | 139 LOG(ERROR) << "Creation of DecryptConfig failed."; |
125 buffer->SetDecryptConfig(config.Pass()); | 140 buffer->SetDecryptConfig(config.Pass()); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 745 } |
731 for (size_t i = 0; i < buffered.size(); ++i) | 746 for (size_t i = 0; i < buffered.size(); ++i) |
732 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 747 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
733 } | 748 } |
734 | 749 |
735 void FFmpegDemuxer::OnDataSourceError() { | 750 void FFmpegDemuxer::OnDataSourceError() { |
736 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 751 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
737 } | 752 } |
738 | 753 |
739 } // namespace media | 754 } // namespace media |
OLD | NEW |