-
Notifications
You must be signed in to change notification settings - Fork 133
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
[Feature Request] Add initial audio codec support #1623
Comments
Hi @KunXi-Fox, Normally you can set the audio track based on codecs before the RxPlayer has made any choice (and thus not have a reload) by reacting to the player.addEventListener("newAvailablePeriods", (periods) => {
for (const period of periods) {
const audioTracks = player.getAvailableAudioTracks(period.id);
// use external logic to select the wanted audio track based on the codec
const chosenAudioTrack = chooseAudioTrack(audioTracks);
if (chosenAudioTrack) {
player.setAudioTrack({
periodId: period.id,
trackId: chosenAudioTrack.id,
});
}
}
}); https://developers.canal-plus.com/rx-player/doc/api/Track_Selection/setAudioTrack.html#setting-the-audio-track-as-soon-as-possible At what point do you update the audio track? If it's e.g. at the |
Yeah, just as you said, I set the initial audio codec at |
Unfortunately, seems |
|
I'm not sure if I understand the problem. For You don't have a |
Hi @peaBerberian , with
Do you have any idea why this happens? |
OK you seem to be encountering an issue. What is the code you're calling on |
something like ⬇ , one more thing is the issue seems only happen on lower end devices, e.g. LG2019, Hisense U4 function handleNewAvailablePeriods(periods) {
for(const period of periods) {
const allTracks = this.getAvailableAudioTracks(
period.id
);
const changeToTrack = allTracks.find(track => track.representations[0]?.codec === this.currentCodec);
if (changeToTrack) {
this.setAudioTrack({
periodId: period.id,
trackId: changeToTrack.id.toString(),
switchingMode: changeToTrack.active ? 'seamless' : 'reload',
})
}
}
} |
Even if we shouldn't have a problem with that, you shouldn't have to call Can you retry without that? I check in the meantime if I can see what happens. |
OK thanks. It could also be helpful to have the full debug logs for that scenario. Can you set: RxPlayer.LogLevel = "DEBUG"
RxPlayer.LogFormat = "full" Reproduce and communicate back logs? |
…cated As #1623 reported, there seem to be an issue seen on lower-end devices where the `TracksStore` gets multiple track references for the same buffer type (`audio`, `video`...) and Period combination. This should __NEVER__ happen as per the `TracksStore` API, there should only be one reference linked to the `TracksStore` for any such combination - if the external logic wanted to update the track reference, it had to call `removeTrackReference` with the previous one (or `resetPeriodObjects` to just reset everything) before adding the new one. Turns out it does happen in some unknown and difficult to reproduce scenario. I guess a race condition allows for some cleaning-up phase to be lost somewhere (either a reset is being skipped - which mostly happens when `RELOADING`, or either some `PeriodStream` cleaning is being missed, which happens when Period switching). So what I propose here isn't a real fix for that problem, but to add some resilience into the TracksStore by considering the last track reference for a buffer type + Period combination - which IMO makes more sense API-wise than keeping the first one and should "fix" cases of infinite rebuffering (as I suppose some code awaited indefinitely that a track choice be performed through that new track reference). The absence of clearing of the previous reference still indicates a leak (though the leak should not matter anymore for the `TracksStore` once the new one is added) and still indicate that something went wrong somewhere, so I kept the `log.error` call which will help us debug other issues that may have their source in that same weird race condition. I'm still looking how such race condition is even possible in the meantime.
…cated As #1623 reported, there seem to be an issue seen on lower-end devices where the `TracksStore` gets multiple track references for the same buffer type (`audio`, `video`...) and Period combination. This should __NEVER__ happen as per the `TracksStore` API, there should only be one reference linked to the `TracksStore` for any such combination - if the external logic wanted to update the track reference, it had to call `removeTrackReference` with the previous one (or `resetPeriodObjects` to just reset everything) before adding the new one. Turns out it does happen in some unknown and difficult to reproduce scenario. I guess a race condition allows for some cleaning-up phase to be lost somewhere (either a reset is being skipped - which mostly happens when `RELOADING`, or either some `PeriodStream` cleaning is being missed, which happens when Period switching). So what I propose here isn't a real fix for that problem, but to add some resilience into the TracksStore by considering the last track reference for a buffer type + Period combination - which IMO makes more sense API-wise than keeping the first one and should "fix" cases of infinite rebuffering (as I suppose some code awaited indefinitely that a track choice be performed through that new track reference). The absence of clearing of the previous reference still indicates a leak (though the leak should not matter anymore for the `TracksStore` once the new one is added) and still indicate that something went wrong somewhere, so I kept the `log.error` call which will help us debug other issues that may have their source in that same weird race condition. I'm still looking how such race condition is even possible in the meantime.
Hi @peaBerberian , below was the detail log: |
BTW, this PR did fix the infinite loading issue even when I saw the error on console. |
Context
Currently rx-player use the first audio codec as default audio codec:
rx-player/src/core/stream/period/period_stream.ts
Lines 472 to 485 in 7b24c52
If I want to use another audio codec based on user preferences, I need to manually call
setAudioTrack
method. This is works at most of cases except the device that not support seamless audio codec switch, which means every audio codec changes will lead to areload
.Solution
Provide a
initialAudioCodec
option and changegetFirstDeclaredMimeType
method to based oninitialAudioCodec
, if noinitialAudioCodec
specified, then fallback to first available audio codec.The text was updated successfully, but these errors were encountered: