Skip to content

Commit b1be3f3

Browse files
authored
v2.2.0 (#79)
* rebuffer controls * fix viewing data irregularities * added video and audio codec to rendition change events
1 parent 5bad5cf commit b1be3f3

File tree

4 files changed

+51
-6
lines changed

4 files changed

+51
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.1.0",
2+
"version": "2.2.0",
33
"main": "./src/mux-analytics.brs",
44
"dependencies": {
55
"@rokucommunity/bslint": "^0.8.9",

sampleapp_source/components_recycled/components/MuxTask.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<field id="disableAutomaticErrorTracking" type="Boolean" alwaysNotify="true" value="false"/>
1212
<field id="randomMuxViewerId" type="Boolean" value="false"/>
1313
<field id="cdn" type="String" alwaysNotify="true" />
14+
<field id="disablePlayheadRebufferTracking" type="Boolean" alwaysNotify="true" value="true" />
15+
<field id="rebufferstart" type="Boolean" alwaysNotify="true" />
16+
<field id="rebufferend" type="Boolean" alwaysNotify="true" />
1417
</interface>
1518
<script type="text/brightscript" uri="pkg:/libs/mux-analytics.brs"/>
1619
</component>

sampleapp_source/components_reset/components/MuxTask.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<field id="disableAutomaticErrorTracking" type="Boolean" alwaysNotify="true" value="false"/>
1313
<field id="randomMuxViewerId" type="Boolean" value="false"/>
1414
<field id="cdn" type="String" alwaysNotify="true" />
15+
<field id="disablePlayheadRebufferTracking" type="Boolean" alwaysNotify="true" value="false" />
16+
<field id="rebufferstart" type="Boolean" alwaysNotify="true" />
17+
<field id="rebufferend" type="Boolean" alwaysNotify="true" />
1518
</interface>
1619
<script type="text/brightscript" uri="pkg:/libs/mux-analytics.brs"/>
1720
</component>

src/mux-analytics.brs

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sub init()
2-
m.MUX_SDK_VERSION = "2.1.0"
2+
m.MUX_SDK_VERSION = "2.2.0"
33
m.top.id = "mux"
44
m.top.functionName = "runBeaconLoop"
55
end sub
@@ -107,11 +107,19 @@ function runBeaconLoop()
107107
end if
108108
m.top.ObserveField("error", m.messagePort)
109109

110-
if m.top.cdn <> invalid
110+
if m.top.cdn <> Invalid
111111
m.mxa.cdnChangeHandler(m.top.cdn)
112112
end if
113113
m.top.ObserveField("cdn", m.messagePort)
114114

115+
if m.top.disablePlayheadRebufferTracking <> Invalid
116+
m.mxa.disablePlayheadRebufferTrackingHandler(m.top.disablePlayheadRebufferTracking)
117+
end if
118+
m.top.ObserveField("disablePlayheadRebufferTracking", m.messagePort)
119+
120+
m.top.ObserveField("rebufferstart", m.messagePort)
121+
m.top.ObserveField("rebufferend", m.messagePort)
122+
115123
m.pollTimer.ObserveField("fire", m.messagePort)
116124
m.beaconTimer.ObserveField("fire", m.messagePort)
117125
m.heartbeatTimer.ObserveField("fire", m.messagePort)
@@ -197,6 +205,12 @@ function runBeaconLoop()
197205
end if
198206
else if field = "cdn"
199207
m.mxa.cdnChangeHandler(msg.getData())
208+
else if field = "disablePlayheadRebufferTracking"
209+
m.mxa.disablePlayheadRebufferTrackingHandler(msg.getData())
210+
else if field = "rebufferstart"
211+
m.mxa.rebufferStartHandler()
212+
else if field = "rebufferend"
213+
m.mxa.rebufferEndHandler()
200214
end if
201215
end if
202216
end if
@@ -392,6 +406,7 @@ function muxAnalytics() as Object
392406
m._viewAdPlayedCount = Invalid
393407
m._viewPrerollPlayedCount = Invalid
394408
m._videoSourceFormat = Invalid
409+
m._audioSourceFormat = Invalid
395410
m._videoSourceDuration = Invalid
396411
m._videoCurrentCdn = Invalid
397412
m._viewPrerollPlayedCount = Invalid
@@ -429,6 +444,7 @@ function muxAnalytics() as Object
429444
m._Flag_FailedAdsErrorSet = false
430445
m._Flag_useSSAI = false
431446
m._Flag_automaticErrorTracking = true
447+
m._Flag_automaticRebufferTracking = true
432448

433449
' Flags specifically for when renderStitchedStream is used
434450
m._Flag_useRenderStitchedStream = false
@@ -515,6 +531,9 @@ function muxAnalytics() as Object
515531
m._Flag_isPaused = (videoState = "paused")
516532

517533
if videoState = "buffering"
534+
' Bail out if we aren't supposed to track automatic rebuffer events
535+
if not m._Flag_automaticRebufferTracking then return
536+
518537
if m._Flag_atLeastOnePlayEventForContent = true
519538
m._addEventToQueue(m._createEvent("rebufferstart"))
520539
m._Flag_RebufferingStarted = true
@@ -530,7 +549,7 @@ function muxAnalytics() as Object
530549
else if videoState = "playing"
531550
m._videoProperties = m._getVideoProperties(m.video)
532551

533-
if m._Flag_lastVideoState = "buffering"
552+
if m._Flag_lastVideoState = "buffering" and m._Flag_automaticRebufferTracking
534553
if m._Flag_RebufferingStarted = true
535554
m._addEventToQueue(m._createEvent("rebufferend"))
536555
m._Flag_RebufferingStarted = false
@@ -700,7 +719,7 @@ function muxAnalytics() as Object
700719
end if
701720
if videoSegment.width <> Invalid AND videoSegment.height <> Invalid AND videoSegment.segBitrateBps <> Invalid
702721
if m._lastSourceWidth <> Invalid AND m._lastSourceWidth <> videoSegment.width OR m._lastSourceHeight <> Invalid AND m._lastSourceHeight <> videoSegment.height OR m._lastVideoSegmentBitrate <> Invalid AND m._lastVideoSegmentBitrate <> videoSegment.segBitrateBps
703-
details = { video_source_width : videoSegment.width, video_source_height : videoSegment.height, video_source_bitrate : videoSegment.segBitrateBps }
722+
details = { video_source_width : videoSegment.width, video_source_height : videoSegment.height, video_source_bitrate : videoSegment.segBitrateBps, video_codec: m._videoSourceFormat, video_audio_codec: m._audioSourceFormat }
704723
m._addEventToQueue(m._createEvent("renditionchange", details))
705724
end if
706725
end if
@@ -865,6 +884,20 @@ function muxAnalytics() as Object
865884
m._addEventToQueue(m._createEvent("error", {player_error_code: errorCode, player_error_message:errorMessage, player_error_context:errorContext, player_error_severity:errorSeverity, player_error_business_exception:isBusinessException}))
866885
end sub
867886

887+
prototype.disablePlayheadRebufferTrackingHandler = sub(disablePlayheadRebufferTracking as Boolean)
888+
if disablePlayheadRebufferTracking <> Invalid
889+
m._Flag_automaticRebufferTracking = (not disablePlayheadRebufferTracking)
890+
end if
891+
end sub
892+
893+
prototype.rebufferStartHandler = sub()
894+
m._addEventToQueue(m._createEvent("rebufferstart"))
895+
end sub
896+
897+
prototype.rebufferEndHandler = sub()
898+
m._addEventToQueue(m._createEvent("rebufferend"))
899+
end sub
900+
868901
prototype.rafEventHandler = sub(rafEvent)
869902
data = rafEvent.getData()
870903
eventType = data.eventType
@@ -1434,6 +1467,10 @@ function muxAnalytics() as Object
14341467
if video.videoFormat <> Invalid AND video.videoFormat <> ""
14351468
m._videoSourceFormat = video.videoFormat
14361469
end if
1470+
1471+
if video.audioFormat <> Invalid AND video.audioFormat <> ""
1472+
m._audioSourceFormat = video.audioFormat
1473+
end if
14371474
end if
14381475

14391476
return props
@@ -1478,7 +1515,9 @@ function muxAnalytics() as Object
14781515
props.video_source_url = content.URL
14791516
props.video_source_hostname = m._getHostname(content.URL)
14801517
props.video_source_domain = m._getDomain(content.URL)
1481-
m._videoSourceFormat = m._getVideoFormat(content.URL)
1518+
if m._videoSourceFormat = Invalid OR m._videoSourceFormat = ""
1519+
m._videoSourceFormat = m._getVideoFormat(content.URL)
1520+
end if
14821521
end if
14831522

14841523
if content.StreamFormat <> Invalid AND (type(content.StreamFormat) = "String" OR type(content.StreamFormat) = "roString") AND content.StreamFormat <> "(null)"

0 commit comments

Comments
 (0)