@newrelic/video-videojs 4.1.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * MediaTailor Constants
3
+ * Contains all regex patterns, config defaults, and constant values for AWS MediaTailor ad tracking
4
+ */
5
+
6
+ // HLS manifest regex patterns used while scanning raw MediaTailor playlists.
7
+ // Example inputs:
8
+ // - #EXT-X-CUE-OUT:DURATION=29.988
9
+ // - #EXT-X-DISCONTINUITY
10
+ // - #EXT-X-MAP:URI="https://segments.mediatailor.../init.mp4"
11
+ export const REGEX_CUE_OUT = /#EXT-X-CUE-OUT:DURATION=([\d.]+)/; // Captures the numeric ad break duration from a MediaTailor CUE-OUT tag so the tracker can seed an ad break before CUE-IN arrives
12
+ export const REGEX_DISCONTINUITY = /#EXT-X-DISCONTINUITY/; // Detects HLS discontinuity boundaries, which MediaTailor playlists can use around ad/content transitions and pod boundaries
13
+ export const REGEX_MAP = /#EXT-X-MAP:URI="([^"]+)"/; // Captures the MAP URI from fMP4 playlists so MAP changes can be used to split one avail into multiple ad pods
14
+
15
+ // MediaTailor URL and manifest regex patterns.
16
+ // These are used to derive the tracking endpoint and to read manifest refresh metadata
17
+ // directly from HLS and DASH payloads.
18
+ export const REGEX_SESSION_ID = /sessionId=([^&]+)/; // Captures the session id from a sessionized playback URL query string such as ?aws.sessionId=abc123 so we can construct the MediaTailor tracking endpoint
19
+ export const REGEX_TRACKING_PATH_SEGMENT = /\/v1\/(master|session|dash)\//; // Matches the playback path prefix in URLs like /v1/master/... or /v1/dash/... so it can be rewritten to /v1/tracking/...
20
+ export const REGEX_MANIFEST_FILE_SUFFIX = /\/[^/]*\.(m3u8|mpd).*$/; // Matches the trailing manifest filename and any query string, such as /master.m3u8?... or /index.mpd?..., so it can be replaced with /{sessionId}
21
+ export const REGEX_HLS_TARGET_DURATION = /#EXT-X-TARGETDURATION:(\d+)/; // Captures the HLS target duration value from a line like #EXT-X-TARGETDURATION:6, which we use as the live polling cadence when available
22
+ export const REGEX_DASH_MINIMUM_UPDATE_PERIOD = /minimumUpdatePeriod="([^"]+)"/; // Captures the DASH MPD minimumUpdatePeriod attribute, for example minimumUpdatePeriod="PT5S", so live polling follows the manifest's declared refresh rate
23
+ export const REGEX_ISO_8601_DURATION = /PT(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?/; // Parses ISO 8601 duration values like PT5S, PT1M14S, or PT1H2M3.5S into hour, minute, and second groups for DASH timing calculations
24
+
25
+ // MediaTailor string markers used across tracker selection and manifest parsing
26
+ export const HLS_MANIFEST_EXTENSION = '.m3u8'; // Identifies HLS manifest URLs and child playlist references
27
+ export const DASH_MANIFEST_EXTENSION = '.mpd'; // Identifies DASH manifest URLs
28
+ export const MEDIATAILOR_HOST_MARKER = '.mediatailor.'; // Identifies MediaTailor playback URLs when selecting this ads tracker
29
+ export const MT_HLS_CUE_OUT_TAG = '#EXT-X-CUE-OUT'; // Marks the start of an HLS ad break in MediaTailor manifests
30
+ export const MT_HLS_CUE_IN_TAG = '#EXT-X-CUE-IN'; // Marks the end of an HLS ad break in MediaTailor manifests
31
+ export const HLS_SEGMENT_DURATION_TAG = '#EXTINF:'; // Carries HLS segment duration values used to advance manifest time
32
+ export const HLS_TAG_PREFIX = '#'; // Distinguishes HLS tags from playlist URI lines in manifest scans
33
+ export const SCTE35_SCHEME_MARKER = 'scte35'; // Identifies SCTE-35 DASH signaling in schemeIdUri values
34
+ export const DASH_SCTE35_EVENT_STREAM_SELECTOR =
35
+ 'EventStream[schemeIdUri*="scte35"], EventStream[schemeIdUri*="SCTE35"]'; // Selects DASH EventStream nodes that carry SCTE-35 ad markers
36
+ export const HLS_MIME_TYPE = 'application/vnd.apple.mpegurl'; // MIME type used to detect Safari/native HLS playback support
37
+
38
+ // MediaTailor URL Patterns
39
+ export const MT_SEGMENT_PATTERN = 'segments.mediatailor'; // Identifies MediaTailor ad segments
40
+
41
+ export const TRACKING_API_TIMEOUT_MS = 5000; // Keep tracking metadata requests within the guide's 5s end-to-end budget
42
+ export const DEFAULT_LIVE_POLL_INTERVAL_MS = 5000; // Temporary fallback until manifest metadata provides cadence
43
+ // Timing Thresholds
44
+ export const MIN_AD_DURATION = 0.5; // Minimum ad duration in seconds (filter false positives)
45
+ export const AD_TIMING_TOLERANCE = 0.5; // Tolerance for matching ad times in seconds
46
+ export const POST_AD_PAUSE_THRESHOLD = 500; // Ignore pause events within 500ms after ad break (avoids false CONTENT_PAUSE)
47
+
48
+ // Stream Types
49
+ export const STREAM_TYPE = {
50
+ VOD: 'vod', // Video on Demand
51
+ LIVE: 'live', // Live streaming
52
+ };
53
+
54
+ // Manifest Types
55
+ export const MANIFEST_TYPE = {
56
+ HLS: 'hls', // HTTP Live Streaming (.m3u8)
57
+ DASH: 'dash', // Dynamic Adaptive Streaming over HTTP (.mpd)
58
+ };
59
+
60
+ // Ad Position Types (for VOD only)
61
+ export const AD_POSITION = {
62
+ PRE_ROLL: 'pre', // First ad break
63
+ MID_ROLL: 'mid', // Middle ad break
64
+ POST_ROLL: 'post', // Last ad break
65
+ };
66
+
67
+ // Ad Detection Sources
68
+ export const AD_SOURCE = {
69
+ MANIFEST_CUE: 'manifest-cue', // Detected from CUE-OUT/CUE-IN tags (HLS) or EventStream (DASH)
70
+ VHS_DISCONTINUITY: 'vhs-discontinuity', // Detected from VHS discontinuityStarts
71
+ TRACKING_API: 'tracking-api', // Added from tracking API response
72
+ MANIFEST_AND_TRACKING: 'manifest+tracking', // Enriched by both sources
73
+ DASH_EMSG: 'dash-emsg', // Detected from DASH emsg events (Shaka Player)
74
+ DASH_EVENT_STREAM: 'dash-event-stream', // Detected from DASH EventStream (dash.js)
75
+ };
76
+
77
+ // Quartile Percentages
78
+ export const QUARTILES = {
79
+ Q1: 0.25, // 25% progress
80
+ Q2: 0.5, // 50% progress
81
+ Q3: 0.75, // 75% progress
82
+ };