-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to by pass audio encoder if pre-encoded set #120
base: m114_release
Are you sure you want to change the base?
Conversation
audio/audio_transport_impl.cc
Outdated
static_cast<uint32_t>(AudioProcessing::NativeRate::kSampleRate8kHz)); | ||
|
||
// 100 = 1 second / data duration (10 ms). | ||
RTC_DCHECK_EQ(nSamples * 100, samplesPerSec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these checks prevent using pre-encoded data? Since it's on the receive end, seems like this should be unaffected? In particular, dropping the 10ms rule seems like a pretty big deal since it's assumed fairly throughout the system that play data would be given in 10ms chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll double check the samples one (it should be fine). For sure if you link rust-sdk examples with debug version of webrtc it will crash in this place, so I commented this block for testing purpose.
#
# Fatal error in: ../../../../_source/macos_arm64/webrtc/src/audio/audio_transport_impl.cc, line 213
# last system error: 0
# Check failed: sizeof(int16_t) * nChannels == nBytesPerSample (4 vs. 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also worried about OggReader where we have:
const OGG_PAGE_DURATION: Duration = Duration::from_millis(20);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can change that to be 10. since webrtc's internal clock for audio is 10ms
api/audio_codecs/audio_encoder.cc
Outdated
const size_t old_size = encoded->size(); | ||
for (const int16_t it : audio) { | ||
uint8_t arr[2] = { | ||
static_cast<uint8_t>((it >> 8) & 0x00ff), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is endianess an issue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed we will have decoder (and this is how I tested), so the most important was to be consistent with decoder.
Otherwise, this is good question. I think I'll convert it to Little Endian (as more popular architecture). Another alternative is to rely on real architecture (by using C like union implementation) or expose this information as part of API, but It may look too complicated, because who knows what output SDP device will decode it.
I uncommented most of checks in
I've also refined encoding. Made it more platform generic (instead of hardcoded big endian). |
Endian I think would work as platform generic? Checked the network code and I think it expects platform endianess anyways. For the nChannels vs. nBytesPerSample check, is this something we can address? |
I'm not 100% sure if it has any impact on workflow (because I've sent PR with fix: livekit/rust-sdks#344 |
This draft PR is an experiment to by-pass audio encoder if
pre_encoded
audio option was set.