Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.cc

Issue 1725143003: Changed AudioEncoder::Encode to take an rtc::Buffer* instead of uint8_t* and a maximum size. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed issues from comments, rewrote MockAudioEncoderHelper Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
12
13 namespace webrtc {
14
15 namespace MockAudioEncoderHelper {
16
17 EncodeFunction FakeEncoding(AudioEncoder::EncodedInfo info) {
18 return [info] (uint32_t timestamp,
19 rtc::ArrayView<const int16_t> audio,
20 rtc::Buffer* encoded) {
21 encoded->SetSize(encoded->size() + info.encoded_bytes);
22 return info;
23 };
24 }
25
26 EncodeFunction FakeEncoding(size_t encoded_bytes) {
27 AudioEncoder::EncodedInfo info;
28 info.encoded_bytes = encoded_bytes;
29 return FakeEncoding(info);
30 }
31
32 EncodeFunction CopyEncoding(AudioEncoder::EncodedInfo info,
33 rtc::ArrayView<const uint8_t> payload) {
34 return [info, payload] (uint32_t timestamp,
35 rtc::ArrayView<const int16_t> audio,
36 rtc::Buffer* encoded) {
37 RTC_CHECK(encoded);
38 RTC_CHECK_LE(info.encoded_bytes, payload.size());
39 encoded->AppendData(payload.data(), info.encoded_bytes);
40 return info;
41 };
42 }
43
44 EncodeFunction CopyEncoding(rtc::ArrayView<const uint8_t> payload) {
45 AudioEncoder::EncodedInfo info;
46 info.encoded_bytes = payload.size();
47 return CopyEncoding(info, payload);
48 }
49
50 DeprecatedEncodeFunction DEPRECATED_CopyEncoding(
51 AudioEncoder::EncodedInfo info,
52 rtc::ArrayView<const uint8_t> payload) {
53 return [info, payload] (uint32_t timestamp,
54 rtc::ArrayView<const int16_t> audio,
55 size_t max_encoded_bytes,
56 uint8_t* encoded) {
57 RTC_CHECK(encoded);
58 RTC_CHECK_LE(info.encoded_bytes, payload.size());
59 std::memcpy(encoded, payload.data(), info.encoded_bytes);
60 return info;
61 };
62 }
63
64 DeprecatedEncodeFunction DEPRECATED_CopyEncoding(
65 rtc::ArrayView<const uint8_t> payload) {
66 AudioEncoder::EncodedInfo info;
67 info.encoded_bytes = payload.size();
68 return DEPRECATED_CopyEncoding(info, payload);
69 }
70
71 } // namespace MockAudioEncoderHelper
72
73 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698