Skip to content

Reinitialize cdm video decoder only when codec change#1001

Merged
glennguy merged 2 commits intoxbmc:Nexusfrom
CastagnaIT:wvswitching
Jun 6, 2022
Merged

Reinitialize cdm video decoder only when codec change#1001
glennguy merged 2 commits intoxbmc:Nexusfrom
CastagnaIT:wvswitching

Conversation

@CastagnaIT
Copy link
Copy Markdown
Collaborator

@CastagnaIT CastagnaIT commented Jun 5, 2022

OpenVideoDecoder is called each time that the stream quality change and currently force call InitializeVideoDecoder in the cdm during playback, at least with N@tflix this cause cdm errors when the stream quality is switched during the playback, so freeze the playback

A possible solution is call DeinitializeDecoder before recall InitializeVideoDecoder,
but as is implemented now cause a delay (image freezed for some secs),

from a search on chromium sources seem that they allow call InitializeVideoDecoder
during playback, but only in the situation that the codec change,
trying to do this i can see that the playback now works when stream quality change,
we will see if someone report a regression but it should not

Since i compared the sources, i took the opportunity to do some cleaning, and to make some parts more similar to chromium conterpart. Changes:

  • DecodeVideo method is now splitted in to: DecryptAndDecodeVideo, VideoFrameDataToPicture
  • Moved host global variable to new Helper.h, to allow have access to log methods without being restricted by each class (in a future prospective to have the main/ssd projects merged)
  • Add cdm_type_conversions.h (adapted from chromium sources) to contains all cdm data type conversions
  • Removed unnecessary reallocations and member variables in WV_CencSingleSampleDecrypter in favour of simple vectors
  • Implemented all fields in SSD_SAMPLE struct, to have full DEMUX_PACKET crypto data

The only functional change in the cleanup is that the cdm::InputBuffer_2 cdm_in; defined in to previous DecodeVideo method
is now constructed by using all info of SSD_SAMPLE (DEMUX_PACKET) data, instead of take some info from members variables like m_CryptBlocks, m_SkipBlocks, m_EncryptionScheme

WIP: not done android side cleanups

@CastagnaIT CastagnaIT added Type: Fix non-breaking change which fixes an issue WIP v20 Nexus Type: Cleanup non-breaking change which removes non-working or unmaintained functionality labels Jun 5, 2022
Copy link
Copy Markdown
Contributor

@glennguy glennguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, looks really good!

@glennguy
Copy link
Copy Markdown
Contributor

glennguy commented Jun 6, 2022

So does this then solve the issue we would have on amlogic/CE devices where video is lost after the first stream change?

@CastagnaIT
Copy link
Copy Markdown
Collaborator Author

CastagnaIT commented Jun 6, 2022

yes tested (with n@tflix) on CoreElec when DEMUX_SPECIALID is signaled not stuck the playback anymore,
although not yet perfect, the quality switching:
-with H264, works but frames seem to be mixed for 1-2 secs, after that playback continues as normal
-with VP9, no problems, as usual the little black screen transition only

comparing to Windows build, the quality switching:
-with H264, works but transition can freeze image for 1 sec, after that playback continues as normal
-with VP9, no problems, transition looks smooth without black screen transition

@glennguy glennguy merged commit 59a026e into xbmc:Nexus Jun 6, 2022
@glennguy
Copy link
Copy Markdown
Contributor

glennguy commented Jun 6, 2022

Great! It's certainly better than no picture at all. Maybe some improvements on Kodi side can make it more seamless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Cleanup non-breaking change which removes non-working or unmaintained functionality Type: Fix non-breaking change which fixes an issue v20 Nexus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants