Skip to content

Core: Local cache for video bids #12598

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

Merged
merged 33 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
29bb63c
Local cache for video bids
mkomorski Nov 26, 2024
a93a356
clean up
mkomorski Nov 26, 2024
ced6862
clean up
mkomorski Nov 26, 2024
3ee5de0
fix
mkomorski Nov 26, 2024
8262d96
error message update
mkomorski Nov 27, 2024
1c438e6
revoking blobs on auction expiry
mkomorski Dec 2, 2024
d76f2c0
Local cache + GAM poc
mkomorski Dec 12, 2024
ba03946
ima sdk adsResponse
mkomorski Dec 17, 2024
1428b06
local cache logic
mkomorski Dec 18, 2024
3477406
dfp function & examples & unit tests
mkomorski Jan 9, 2025
939f476
fix order
mkomorski Jan 9, 2025
043da56
reorganization
mkomorski Jan 9, 2025
2ae48c0
refactor
mkomorski Jan 9, 2025
25a5081
Merge branch 'master' into mkomorski/local-cache-gam
mkomorski Jan 13, 2025
3cd0d83
lint fix
mkomorski Jan 14, 2025
bafe1b6
introducing setAdXml
mkomorski Jan 27, 2025
49e78ba
Merge branch 'master' into mkomorski/local-cache-gam
mkomorski Jan 27, 2025
a58ed31
Merge branch 'master' into mkomorski/local-cache-gam
mkomorski Jan 29, 2025
584d02a
renderBid change
mkomorski Jan 29, 2025
4fd2566
removing getVast from pbjs
mkomorski Feb 13, 2025
d75e68b
review fixes
mkomorski Feb 18, 2025
c914e70
limiting use of prefetching vast to local cache
mkomorski Feb 19, 2025
bda8c38
revert not needed
mkomorski Feb 19, 2025
84dc8ba
adapting to 'send all bids', adding some tests
mkomorski Mar 1, 2025
726dfa2
+ regexp
mkomorski Mar 3, 2025
f642b7f
regexp fix
mkomorski Mar 3, 2025
50a314f
regexp fix
mkomorski Mar 3, 2025
f28fd2f
uuid matching refactor
mkomorski Mar 4, 2025
8dc82f7
Update integrationExamples/videoModule/jwplayer/localVideoCache.html
mkomorski Mar 4, 2025
92ca58d
remove unecessary parts
mkomorski Mar 11, 2025
1c78154
lint fix
mkomorski Mar 11, 2025
3f9f216
remove not needed test
mkomorski Mar 11, 2025
bb17aef
Merge branch 'master' into mkomorski/local-cache-gam
mkomorski Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions integrationExamples/gpt/localCacheGam.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<html>

<head>
<script src="https://cdn.jwplayer.com/libraries/l5MchIxB.js"></script>
<script async src="../../../build/dev/prebid.js"></script>

<title>JW Player with Local Cache</title>

<script>
// Setup ad units
var adUnits = [{
code: 'div-gpt-ad-51545-0',
mediaTypes: {
video: {
playerSize: [640, 360],
}
},
video: {
divId: 'player', // required to indicate which player is being used to render this ad unit.
},

bids: [{
bidder: 'jwplayer',
params: {
publisherId: 'test-publisher-id',
siteId: 'test-site-id',
placementId: 'test-placement-id'
}
}, {
bidder: 'ix',
params: {
siteId: '300',
}
}]
}];
const vastXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><VAST version=\"3.0\"><Ad><InLine><AdSystem>GDFP</AdSystem><AdTitle>Demo</AdTitle><Description><![CDATA[Demo]]></Description><Creatives><Creative><Linear ><Duration>00:00:11</Duration><VideoClicks><ClickThrough><![CDATA[https://adplayer.pro/]]></ClickThrough></VideoClicks><MediaFiles><MediaFile delivery=\"progressive\" width=\"640\" height=\"360\" type=\"video/mp4\" scalable=\"true\" maintainAspectRatio=\"true\"><![CDATA[https://static.adplayer.pro/video/demo_v2.mp4]]></MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>"

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function () {
pbjs.setConfig({
cache: {
useLocal: true
},
debugging: {
enabled: true,
intercept: [
{
when: {
adUnitCode: 'div-gpt-ad-51545-0',
},
then: {
cpm: 25,
mediaType: "video",
vastXml
}
},
]
}
});
pbjs.addAdUnits(adUnits);

pbjs.onEvent('videoSetupComplete', e => {
console.log('player setup complete: ', e);
});

pbjs.onEvent('videoSetupFailed', e => {
console.log('player setup failed: ', e);
});

pbjs.onEvent('videoPlaylist', (e) => {
console.log('videos pb playlist: ', e);
});

// request a bid when media is loaded
pbjs.onEvent('videoContentLoaded', (e) => {
console.log('videos pb contentLoaded: ', e);
});

pbjs.onEvent('videoComplete', (e) => {
console.log('videos pb complete: ', e);
});

pbjs.onEvent('videoPlaylistComplete', (e) => {
console.log('videos pb playlistComplete: ', e);
});

pbjs.requestBids({
bidsBackHandler: async function(bidResponses) {
const bidResponse = bidResponses['div-gpt-ad-51545-0'];
if (!bidResponse) {
return;
}

const bid = bidResponse.bids[0];

const vastXml = await pbjs.adServers.dfp.getAdXml({
bid,
adUnit: 'div-gpt-ad-51545-0',
params: {
iu: '/41758329/localcache',
url: "https://pubads.g.doubleclick.net/gampad/ads?iu=/41758329/localcache&sz=640x480&gdfp_req=1&output=vast&env=vp",
}
});

jwplayer("player").setup({
playlist: "https://cdn.jwplayer.com/v2/media/hWF9vG66",
autostart: "viewable",
advertising: {
client: "vast",
schedule: [
{
vastxml: vastXml,
offset: 'pre'
}
]
}
});
}
});
});
</script>

</head>

<body>
<h2>JW Player with Local cache</h2>

<h5>Div-1: Player placeholder div</h5>
<div id='player'></div>
</body>

</html>
167 changes: 167 additions & 0 deletions integrationExamples/videoModule/adPlayerPro/localVideoCache.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@

<html lang="en">

<head>
<script src="https://serving.stat-rock.com/player/prebidAdPlayerPro.js"></script>
<script async src="../../../build/dev/prebid.js"></script>

<title>AdPlayer.Pro with Local Cache & GAM</title>

<script>
// Setup ad units
var adUnits = [{
code: 'div-gpt-ad-51545-0',
mediaTypes: {
video: {
playerSize: [640, 360],
}
},
video: {
divId: 'player', // required to indicate which player is being used to render this ad unit.
},
bids: [
{
bidder: 'ix',
params: {
siteId: '300',
}
}
]
}];

const vastXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><VAST version=\"3.0\"><Ad><InLine><AdSystem>GDFP</AdSystem><AdTitle>Demo</AdTitle><Description><![CDATA[Demo]]></Description><Creatives><Creative><Linear ><Duration>00:00:11</Duration><VideoClicks><ClickThrough><![CDATA[https://adplayer.pro/]]></ClickThrough></VideoClicks><MediaFiles><MediaFile delivery=\"progressive\" width=\"640\" height=\"360\" type=\"video/mp4\" scalable=\"true\" maintainAspectRatio=\"true\"><![CDATA[https://static.adplayer.pro/video/demo_v2.mp4]]></MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>"

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function () {
pbjs.setConfig({
cache: {
useLocal: true
},
video: {
providers: [{
divId: 'player', // required, this is the id of the div element where the player will be placed
vendorCode: 3, // AdPlayer.Pro vendorCode
playerConfig: {
placementId: 'c9gebfehcqjE', // required, this placementId is only for demo purposes
params: {
type: 'inView',
muted: true,
autoStart: true,
width: 640,
height: 360,
advertising: {
closeButton: true,
// 'tag': {'client': 'googima'},
}
}
},
adServer: {
vendorCode: 'gam',
baseAdTagUrl: 'https://pubads.g.doubleclick.net/gampad/ads?iu=/41758329/localcache&sz=640x480&gdfp_req=1&output=vast&env=vp'
},
}]
},
//settings for demo only
debugging: {
enabled: true,
intercept: [
{
when: {
adUnitCode: 'div-gpt-ad-51545-0',
},
then: {
context: "outstream",
cpm: 10,
mediaType: "video",
// vastUrl: url,
vastXml,
renderer: {},
}
},
]
},
consentManagement: {cmpApi: 'static', consentData: {getTCData: {gdprApplies: false}}},
bidResponseFilter: {cat: {blockUnknown: false}, adv: {blockUnknown: false}, attr: {blockUnknown: false}}
});
pbjs.addAdUnits(adUnits);

pbjs.onEvent('videoSetupComplete', e => {
console.log('player setup complete: ', e);
});

pbjs.onEvent('videoSetupFailed', e => {
console.log('player setup failed: ', e);
});

pbjs.onEvent('videoDestroyed', e => {
console.log('player destroyed: ', e);
});

pbjs.onEvent('videoAdImpression', (e) => {
console.log('videos pb ad impression: ', e);
});

pbjs.onEvent('videoAdStarted', (e) => {
console.log('videos pb ad started: ', e);
});

pbjs.onEvent('videoAdPlay', (e) => {
console.log('videos pb ad play: ', e);
});

pbjs.onEvent('videoAdPause', (e) => {
console.log('videos pb ad pause: ', e);
});

pbjs.onEvent('videoAdComplete', (e) => {
console.log('videos pb ad complete: ', e);
});

pbjs.onEvent('videoAdSkipped', (e) => {
console.log('videos pb ad skipped: ', e);
});

pbjs.onEvent('videoAdClick', (e) => {
console.log('videos pb ad click: ', e);
});

pbjs.onEvent('videoAdError', (e) => {
console.log('videos pb ad error: ', e);
});

pbjs.onEvent('videoAuctionAdLoadAttempt', (e) => {
console.log('videos pb auction ad load attempt: ', e);
});

pbjs.onEvent('videoAuctionAdLoadQueued', (e) => {
console.log('videos pb auction ad load queued: ', e);
});

pbjs.onEvent('videoAuctionAdLoadAbort', (e) => {
console.log('videos pb auction ad load attempt: ', e);
});

pbjs.onEvent('videoBidImpression', (e) => {
console.log('videos pb bid Impression: ', e);
});

pbjs.onEvent('videoBidError', (e) => {
console.log('videos pb bid Error: ', e);
});

pbjs.requestBids();
});
</script>

</head>

<body>
<h2>AdPlayer.Pro with Local Cache & GAM</h2>

<h5>Div-1: Player placeholder div</h5>
<div id='player'></div>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ <h5>Div-1: Player placeholder div</h5>
<div id ="player"></div>
</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
// output: 'vast'
// },
baseAdTagUrl: 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator='
//'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/137679306/HB_Dev_Center_Example&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&correlator=',
},
},]
},
Expand Down
Loading