Closed Bug 1702646 Opened 4 years ago Closed 3 years ago

Separate AudioInputTrack into NativeInputTrack and AudioProcessingTrack

Categories

(Core :: Audio/Video: MediaStreamGraph, task, P1)

task

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: chunmin, Assigned: chunmin)

References

Details

Attachments

(5 files, 1 obsolete file)

Now AudioInputTrack is the source of the MediaStreamTrack, which is created from getUserMedia at first, to get the microphone data. It has an AudioDataListener member to handle the audio input data from the microphone and an AudioInputProcessing member to apply the audio processing configured by the MediaTrackConstraints.

To make multiple microphones work in the same MediaTrackGraph which is driven by a certain audio device, we need to separate the AudioInputTrack into two tracks:

  1. NativeInputTrack
    • handle the audio input data from the microphone
  2. AudioProcessingTrack:
    • is the source of the MediaStreamTrack
    • apply the audio processing configured by the MediaTrackConstraints for the MediaStreamTrack

and they will be linked via a MediaInputPort

By doing so, the AudioProcessingTrack, which is paired to a MediaStreamTrack, can use a different source track than the NativeInputTrack when we are able to open another microphone in the MediaTrackGraph, if the user asks to create another MediaStreamTrack from another microphone device

Summary: Refactor AudioInputTrack → Separate AudioInputTrack into NativeInputTrack and AudioProcessingTrack
Severity: -- → S3
Blocks: 1238038

Draft will be on this branch. The below commits will be updated from times to times here:

Depends on: 1706524

Replace mInputDeviceUsers by a <device-id, NativeInputTrack> map

Remove mDataUsers in NativeInputTrack. We can deliver audio data
via NativeInputTrack's data consumer tracks directly.


This patch demonstrates a way to deliver audio data from NativeInputTrack to AudioInputTrack from MediaInputPort directly, without using a nsTArray<RefPtr<AudioDataListener>> list to track the data receiver in AudioInputTrack. However, we need to make sure the AudioInputTrack::CloseAudioInputis called before the MediaInputPort is destroyed and we will use raw pointers all the times. I am not sure if it's a good way to go now.

Depends on D113680

The final goal is to get the input audio data from MediaInputPort, so we
move the data receiving and processing from NotifyInputData to
ProcessInput, which is a new function created in this patch.

Attachment #9221249 - Attachment description: WIP: Bug 1702646 - Move data processing from NotifyInputData to ProcessInput → WIP: Bug 1702646 - Process audio input in ProcessInput
Attachment #9221242 - Attachment description: WIP: Bug 1702646 - Use AudioSegment to deliver data → WIP: Bug 1702646 - Get audio input data from GetData
Attachment #9218993 - Attachment description: WIP: Bug 1702646 - Use NativeInputTrack to deliver audio data → Bug 1702646 - Use NativeInputTrack to deliver audio data
Attachment #9221249 - Attachment description: WIP: Bug 1702646 - Process audio input in ProcessInput → Bug 1702646 - Process audio input in ProcessInput
Attachment #9221242 - Attachment description: WIP: Bug 1702646 - Get audio input data from GetData → Bug 1702646 - Get audio input data from GetData
Attachment #9218993 - Attachment description: Bug 1702646 - Use NativeInputTrack to deliver audio data → WIP: Bug 1702646 - Use NativeInputTrack to deliver audio data
Attachment #9221249 - Attachment description: Bug 1702646 - Process audio input in ProcessInput → WIP: Bug 1702646 - Process audio input in ProcessInput
Attachment #9221242 - Attachment description: Bug 1702646 - Get audio input data from GetData → WIP: Bug 1702646 - Get audio input data from GetData
Attachment #9218993 - Attachment description: WIP: Bug 1702646 - Use NativeInputTrack to deliver audio data → Bug 1702646 - Use NativeInputTrack to deliver audio data
Attachment #9221249 - Attachment description: WIP: Bug 1702646 - Process audio input in ProcessInput → Bug 1702646 - Process audio input in ProcessInput
Attachment #9221242 - Attachment description: WIP: Bug 1702646 - Get audio input data from GetData → Bug 1702646 - Share AudioSegments among AudioInputTrack
Attachment #9220224 - Attachment is obsolete: true
Pushed by cchang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f87a905f445a Use NativeInputTrack to deliver audio data r=padenot https://hg.mozilla.org/integration/autoland/rev/13dc1577b2a0 Process audio input in ProcessInput r=padenot https://hg.mozilla.org/integration/autoland/rev/2b5f35e21e84 Share AudioSegments among AudioInputTrack r=padenot

The AudioInputProcessing now needs to call ProcessInput to process the
given input data instead of processing them in NotifyInputData

Add an utility function named AppendFromInterleavedBuffer in
AudioSegment to append data from the given interleaved buffer. This
function does the same job as what AudioInputProcessing::InsertInGraph
and NativeInputTrack::ProcessInput were used to do. As a result, these
two functions can be eliminated or simplified.

Depends on D116673

(In reply to Noemi Erli[:noemi_erli] from comment #7)

Log: https://treeherder.mozilla.org/logviewer?job_id=341513992&repo=autoland&lineNumber=4035

The following crash is expected. Do not panic.

./mach gtest PLDHashTableTest.InitCapacityOk intends to cause crashes. Nothing needs to worry about here ( Do not panic ;) ). In addition, I don't think my code touches any hash-table implementation.

https://treeherder.mozilla.org/logviewer?job_id=341513233&repo=autoland&lineNumber=30166

This is the only thing we should take care of. D116673 should fix the problem.

Flags: needinfo?(cchang)
Pushed by cchang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dad561cb1cfb Use NativeInputTrack to deliver audio data r=padenot https://hg.mozilla.org/integration/autoland/rev/98aad7de92bf Process audio input in ProcessInput r=padenot https://hg.mozilla.org/integration/autoland/rev/303bfb969f52 Share AudioSegments among AudioInputTrack r=padenot https://hg.mozilla.org/integration/autoland/rev/c450c5d35c61 Fix TestAudioInputProcessing tests r=padenot https://hg.mozilla.org/integration/autoland/rev/f0c736218ab6 Add an util-function to append interleaved buffer in AudioSegment r=padenot
Regressions: 1725810
Regressions: 1732466
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: