Skip to content

Commit

Permalink
Support of outstream renderer in oneVideo Adaptor (#3959)
Browse files Browse the repository at this point in the history
* outstream changes

* removing global filtet

* reverting page

* message

* adapter change

* remove space

* testcases

* testpage

* spaces for test page

* renderer exist case

* reverting package-lock.json
  • Loading branch information
DeepthiNeeladri authored and jaiminpanchal27 committed Jul 9, 2019
1 parent 2e0ea78 commit 3e6460d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
22 changes: 20 additions & 2 deletions modules/oneVideoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,22 @@ export const spec = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: bid.price,
creativeId: bid.id,
adId: bid.adid,
creativeId: bid.crid,
width: size.width,
height: size.height,
mediaType: 'video',
currency: response.cur,
ttl: 100,
netRevenue: true
netRevenue: true,
adUnitCode: bidRequest.adUnitCode
};
if (bid.nurl) {
bidResponse.vastUrl = bid.nurl;
} else if (bid.adm) {
bidResponse.vastXml = bid.adm;
}
bidResponse.renderer = (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined;
return bidResponse;
},
/**
Expand Down Expand Up @@ -216,5 +219,20 @@ function getRequestData(bid, consentData) {
function isSecure() {
return document.location.protocol === 'https:';
}
/**
* Create oneVideo renderer
* @returns {*}
*/
function newRenderer(bidRequest, bid) {
if (!bidRequest.renderer) {
bidRequest.renderer = {};
bidRequest.renderer.url = 'https://cdn.vidible.tv/prod/hb-outstream-renderer/renderer.js';
bidRequest.renderer.render = function(bid) {
setTimeout(function () {
o2PlayerRender(bid);
}, 700)
};
}
}

registerBidder(spec);
2 changes: 1 addition & 1 deletion test/pages/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ <h2>Prebid Video -- video.js</h2>

</script>
</body>
</html>
</html>
16 changes: 13 additions & 3 deletions test/spec/modules/oneVideoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ describe('OneVideoBidAdapter', function () {

beforeEach(function () {
bidRequest = {
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 480]
}
},
bidder: 'oneVideo',
sizes: [640, 480],
bidId: '30b3efwfwe1e',
adUnitCode: 'video1',
params: {
video: {
playerWidth: 640,
Expand Down Expand Up @@ -140,20 +147,23 @@ describe('OneVideoBidAdapter', function () {
});

it('should return a valid bid response with just "adm"', function () {
const serverResponse = {seatbid: [{bid: [{id: 1, price: 6.01, adm: '<VAST></VAST>'}]}], cur: 'USD'};
const serverResponse = {seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: '<VAST></VAST>'}]}], cur: 'USD'};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
let o = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: serverResponse.seatbid[0].bid[0].price,
creativeId: serverResponse.seatbid[0].bid[0].id,
adId: serverResponse.seatbid[0].bid[0].adid,
creativeId: serverResponse.seatbid[0].bid[0].crid,
vastXml: serverResponse.seatbid[0].bid[0].adm,
width: 640,
height: 480,
mediaType: 'video',
currency: 'USD',
ttl: 100,
netRevenue: true
netRevenue: true,
adUnitCode: bidRequest.adUnitCode,
renderer: (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined,
};
expect(bidResponse).to.deep.equal(o);
});
Expand Down

0 comments on commit 3e6460d

Please sign in to comment.