Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jimdogx committed Nov 18, 2024
1 parent 89160be commit 0a41916
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions components/ItemGrid/LoadVideoContentTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,23 @@ sub loadItems()
id = m.top.itemId
mediaSourceId = invalid
audio_stream_idx = m.top.selectedAudioStreamIndex
if m.top.transcodeLiveTV = true
forceTranscoding = false
forceMP3Audio = false
if m.top.forceTranscodeMP3Audio = true
print "forcing retry of Live TV with transcoding..."
forceTranscoding = true
else
forceTranscoding = false
forceMP3Audio = true
end if

m.top.content = [LoadItems_VideoPlayer(id, mediaSourceId, audio_stream_idx, forceTranscoding)]
m.top.content = [LoadItems_VideoPlayer(id, mediaSourceId, audio_stream_idx, forceTranscoding, forceMP3Audio)]
end sub

function LoadItems_VideoPlayer(id as string, mediaSourceId = invalid as dynamic, audio_stream_idx = 1 as integer, forceTranscoding = false as boolean) as dynamic
function LoadItems_VideoPlayer(id as string, mediaSourceId = invalid as dynamic, audio_stream_idx = 1 as integer, forceTranscoding = false as boolean, forceMP3Audio = false as boolean) as dynamic

video = {}
video.id = id
video.content = createObject("RoSGNode", "ContentNode")

LoadItems_AddVideoContent(video, mediaSourceId, audio_stream_idx, forceTranscoding)
LoadItems_AddVideoContent(video, mediaSourceId, audio_stream_idx, forceTranscoding, forceMP3Audio)

if video.content = invalid
return invalid
Expand All @@ -76,7 +76,7 @@ function LoadItems_VideoPlayer(id as string, mediaSourceId = invalid as dynamic,
return video
end function

sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_stream_idx = 1 as integer, forceTranscoding = false as boolean)
sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_stream_idx = 1 as integer, forceTranscoding = false as boolean, forceMP3Audio = false as boolean)

meta = ItemMetaData(video.id)
if not isValid(meta)
Expand Down Expand Up @@ -167,7 +167,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
if not isValid(mediaSourceId) then mediaSourceId = video.id
if meta.live then mediaSourceId = ""

m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition, forceTranscoding)
m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition, forceMP3Audio)
if not isValid(m.playbackInfo)
video.errorMsg = "Error loading playback info"
video.content = invalid
Expand All @@ -184,7 +184,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
video.SelectedSubtitle = defaultSubtitleIndex
subtitle_idx = defaultSubtitleIndex

m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition, forceTranscoding)
m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition, forceMP3Audio)
if not isValid(m.playbackInfo)
video.errorMsg = "Error loading playback info"
video.content = invalid
Expand Down
2 changes: 1 addition & 1 deletion components/ItemGrid/LoadVideoContentTask.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<!-- Total records available from server-->
<field id="totalRecordCount" type="int" value="-1" />
<field id="content" type="array" />
<field id="transcodeLiveTV" type="boolean" value="false" />
<field id="forceTranscodeMP3Audio" type="boolean" value="false" />
</interface>
</component>
2 changes: 1 addition & 1 deletion components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ sub onAudioIndexChange()
end sub

sub RetryLiveTV()
m.LoadMetaDataTask.transcodeLiveTV = true
m.LoadMetaDataTask.forceTranscodeMP3Audio = true
m.LoadMetaDataTask.selectedSubtitleIndex = m.top.SelectedSubtitle
m.LoadMetaDataTask.selectedAudioStreamIndex = m.top.audioIndex
m.LoadMetaDataTask.itemId = m.currentItem.id
Expand Down
10 changes: 5 additions & 5 deletions source/api/Items.bs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ItemGetPlaybackInfo(id as string, startTimeTicks = 0 as longinteger)
return getJson(resp)
end function

function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioTrackIndex = -1 as integer, subtitleTrackIndex = -1 as integer, startTimeTicks = 0 as longinteger, forceLiveTVTranscode = false)
function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioTrackIndex = -1 as integer, subtitleTrackIndex = -1 as integer, startTimeTicks = 0 as longinteger, forceMP3 = false)
params = {
"UserId": m.global.session.user.id,
"StartTimeTicks": startTimeTicks,
Expand All @@ -39,16 +39,16 @@ function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioT

myGLobal = m.global

if audioTrackIndex > -1 and myGLobal.session.video.json.MediaStreams <> invalid or forceLiveTVTranscode
if audioTrackIndex > -1 and myGLobal.session.video.json.MediaStreams <> invalid or forceMP3
selectedAudioStream = myGLobal.session.video.json.MediaStreams[audioTrackIndex]

if selectedAudioStream <> invalid or forceLiveTVTranscode
if selectedAudioStream <> invalid or forceMP3
params.AudioStreamIndex = audioTrackIndex

' force the server to transcode AAC profiles we don't support to MP3 instead of the usual AAC
' TODO: Remove this after server adds support for transcoding AAC from one profile to another
if forceLiveTVTranscode or selectedAudioStream.Codec <> invalid and LCase(selectedAudioStream.Codec) = "aac"
if forceLiveTVTranscode or selectedAudioStream.Profile <> invalid and LCase(selectedAudioStream.Profile) = "main" or LCase(selectedAudioStream.Profile) = "he-aac"
if forceMP3 or selectedAudioStream.Codec <> invalid and LCase(selectedAudioStream.Codec) = "aac"
if forceMP3 or selectedAudioStream.Profile <> invalid and LCase(selectedAudioStream.Profile) = "main" or LCase(selectedAudioStream.Profile) = "he-aac"
for each rule in deviceProfile.TranscodingProfiles
if rule.Container = "ts" or rule.Container = "mp4"
if rule.AudioCodec = "aac"
Expand Down

0 comments on commit 0a41916

Please sign in to comment.