| 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 "media/capture/webm_muxer.h" | 5 #include "media/capture/webm_muxer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "media/audio/audio_parameters.h" | 8 #include "media/audio/audio_parameters.h" |
| 9 #include "media/base/limits.h" | 9 #include "media/base/limits.h" |
| 10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // Set channel mapping. | 38 // Set channel mapping. |
| 39 if (params.channels() > 2) { | 39 if (params.channels() > 2) { |
| 40 // Also possible to have a multistream, not supported for now. | 40 // Also possible to have a multistream, not supported for now. |
| 41 DCHECK_LE(params.channels(), OPUS_MAX_VORBIS_CHANNELS); | 41 DCHECK_LE(params.channels(), OPUS_MAX_VORBIS_CHANNELS); |
| 42 header[OPUS_EXTRADATA_CHANNEL_MAPPING_OFFSET] = 1; | 42 header[OPUS_EXTRADATA_CHANNEL_MAPPING_OFFSET] = 1; |
| 43 // Assuming no coupled streams. This should actually be | 43 // Assuming no coupled streams. This should actually be |
| 44 // channels() - |coupled_streams|. | 44 // channels() - |coupled_streams|. |
| 45 header[OPUS_EXTRADATA_NUM_STREAMS_OFFSET] = params.channels(); | 45 header[OPUS_EXTRADATA_NUM_STREAMS_OFFSET] = params.channels(); |
| 46 header[OPUS_EXTRADATA_NUM_COUPLED_OFFSET] = 0; | 46 header[OPUS_EXTRADATA_NUM_COUPLED_OFFSET] = 0; |
| 47 // Set the actual stream map. | 47 // Set the actual stream map. |
| 48 memcpy(header + OPUS_EXTRADATA_STREAM_MAP_OFFSET, | 48 for (int i = 0; i < params.channels(); ++i) { |
| 49 kOpusVorbisChannelMap[params.channels() - 1], params.channels()); | 49 header[OPUS_EXTRADATA_STREAM_MAP_OFFSET + i] = |
| 50 kOpusVorbisChannelMap[params.channels() - 1][i]; |
| 51 } |
| 50 } else { | 52 } else { |
| 51 header[OPUS_EXTRADATA_CHANNEL_MAPPING_OFFSET] = 0; | 53 header[OPUS_EXTRADATA_CHANNEL_MAPPING_OFFSET] = 0; |
| 52 } | 54 } |
| 53 } | 55 } |
| 54 | 56 |
| 55 static double GetFrameRate(const scoped_refptr<VideoFrame>& video_frame) { | 57 static double GetFrameRate(const scoped_refptr<VideoFrame>& video_frame) { |
| 56 const double kZeroFrameRate = 0.0; | 58 const double kZeroFrameRate = 0.0; |
| 57 const double kDefaultFrameRate = 30.0; | 59 const double kDefaultFrameRate = 30.0; |
| 58 | 60 |
| 59 double frame_rate = kDefaultFrameRate; | 61 double frame_rate = kDefaultFrameRate; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 247 } |
| 246 | 248 |
| 247 void WebmMuxer::ElementStartNotify(mkvmuxer::uint64 element_id, | 249 void WebmMuxer::ElementStartNotify(mkvmuxer::uint64 element_id, |
| 248 mkvmuxer::int64 position) { | 250 mkvmuxer::int64 position) { |
| 249 // This method gets pinged before items are sent to |write_data_callback_|. | 251 // This method gets pinged before items are sent to |write_data_callback_|. |
| 250 DCHECK_GE(position, position_.ValueOrDefault(0)) | 252 DCHECK_GE(position, position_.ValueOrDefault(0)) |
| 251 << "Can't go back in a live WebM stream."; | 253 << "Can't go back in a live WebM stream."; |
| 252 } | 254 } |
| 253 | 255 |
| 254 } // namespace media | 256 } // namespace media |
| OLD | NEW |