OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 } | 306 } |
307 | 307 |
308 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { | 308 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { |
309 return RtpStreamId::ValueSize(rsid); | 309 return RtpStreamId::ValueSize(rsid); |
310 } | 310 } |
311 | 311 |
312 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { | 312 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { |
313 return RtpStreamId::Write(data, rsid); | 313 return RtpStreamId::Write(data, rsid); |
314 } | 314 } |
315 | 315 |
316 // For Frame Marking RTP Header Extension: | |
317 // | |
318 // https://tools.ietf.org/html/draft-ietf-avtext-framemarking-04#page-4 | |
319 // This extensions provides meta-information about the RTP streams outside the | |
320 // encrypted media payload, an RTP switch can do codec-agnostic | |
321 // selective forwarding without decrypting the payload. | |
322 // | |
323 // for Non-Scalable Streams: | |
324 // | |
325 // 0 1 | |
326 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | |
327 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
328 // | ID=? | L=0 |S|E|I|D|0 0 0 0| | |
329 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
330 // | |
331 // for Scalable Streams: | |
332 // | |
333 // 0 1 2 3 | |
334 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
335 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
336 // | ID=? | L=2 |S|E|I|D|B| TID | LID | TL0PICIDX | | |
337 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
338 // | |
339 constexpr RTPExtensionType FrameMarking::kId; | |
340 constexpr const char* FrameMarking::kUri; | |
341 | |
342 bool FrameMarking::Parse(rtc::ArrayView<const uint8_t> data, | |
343 FrameMarks* frame_marks) { | |
344 RTC_DCHECK(frame_marks); | |
345 | |
346 if (data.empty()) | |
347 return false; | |
348 | |
349 // Set frame marking data | |
350 frame_marks->start_of_frame = (data[0] & 0x80) != 0; | |
351 frame_marks->end_of_frame = (data[0] & 0x40) != 0; | |
352 frame_marks->independent = (data[0] & 0x20) != 0; | |
353 frame_marks->discardable = (data[0] & 0x10) != 0; | |
354 | |
355 // Check variable length. | |
356 if (data.size() == 1) { | |
357 // We are non-scalable. | |
358 frame_marks->base_layer_sync = false; | |
359 frame_marks->temporal_layer_id = 0; | |
360 frame_marks->layer_id = 0; | |
361 frame_marks->tl0_pic_idx = 0; | |
362 } else if (data.size() == 3) { | |
363 // Set scalable parts | |
364 frame_marks->base_layer_sync = (data[0] & 0x08) != 0; | |
365 frame_marks->temporal_layer_id = data[0] & 0x07; | |
366 frame_marks->layer_id = data[1]; | |
367 frame_marks->tl0_pic_idx = data[2]; | |
368 } else { | |
369 // Incorrect length. | |
370 return false; | |
371 } | |
372 return true; | |
373 } | |
374 | |
375 size_t FrameMarking::ValueSize(const FrameMarks& frame_marks) { | |
376 // Check if it is scalable. | |
377 if (frame_marks.base_layer_sync || | |
378 (frame_marks.temporal_layer_id && | |
379 frame_marks.temporal_layer_id != kNoTemporalIdx) || | |
380 (frame_marks.layer_id && frame_marks.layer_id != kNoSpatialIdx) || | |
381 (frame_marks.tl0_pic_idx && | |
382 frame_marks.tl0_pic_idx != static_cast<uint8_t>(kNoTl0PicIdx))) | |
danilchap
2017/06/30 12:53:25
does it make 0xff picture id invalid?
may be inste
sergio.garcia.murillo
2017/06/30 13:42:00
Agree, changing it to int so it matches the other
| |
383 return 3; | |
384 else | |
385 return 1; | |
386 } | |
387 | |
388 bool FrameMarking::Write(uint8_t* data, const FrameMarks& frame_marks) { | |
389 data[0] = frame_marks.start_of_frame ? 0x80 : 0x00; | |
390 data[0] |= frame_marks.end_of_frame ? 0x40 : 0x00; | |
391 data[0] |= frame_marks.independent ? 0x20 : 0x00; | |
392 data[0] |= frame_marks.discardable ? 0x10 : 0x00; | |
393 | |
394 // Check if it is scalable. | |
395 if (frame_marks.base_layer_sync || | |
396 (frame_marks.temporal_layer_id && | |
397 frame_marks.temporal_layer_id != kNoTemporalIdx) || | |
398 (frame_marks.layer_id && frame_marks.layer_id != kNoSpatialIdx) || | |
399 (frame_marks.tl0_pic_idx && | |
400 frame_marks.tl0_pic_idx != static_cast<uint8_t>(kNoTl0PicIdx))) { | |
danilchap
2017/06/30 12:53:25
same here (since this check is large and non-trivi
sergio.garcia.murillo
2017/06/30 13:42:00
Done.
| |
401 data[0] |= frame_marks.base_layer_sync ? 0x08 : 0x00; | |
402 data[0] |= (frame_marks.temporal_layer_id & 0x07); | |
403 data[1] = frame_marks.layer_id; | |
404 data[2] = frame_marks.tl0_pic_idx; | |
405 } | |
406 return true; | |
407 } | |
408 | |
409 uint8_t FrameMarking::CreateLayerId(RTPVideoHeaderVP9 vp9) { | |
410 // The following shows VP9 Layer encoding information (3 bits for | |
411 // spatial and temporal layer) mapped to the generic LID and TID fields. | |
412 // The P and U bits MUST match the corresponding bits in the VP9 Payload | |
413 // Description. | |
414 // 0 1 2 3 | |
415 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
416 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
417 // | ID=2 | L=2 |S|E|I|D|B| TID |0|0|0|P|U| SID | TL0PICIDX | | |
danilchap
2017/06/30 12:53:25
linked spec has different format for VP9 LID Mappi
sergio.garcia.murillo
2017/06/30 13:42:00
Current draft has invalid format for LID. Spatial
| |
418 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
419 return (vp9.spatial_idx != kNoSpatialIdx ? vp9.spatial_idx & 0x07 : 0x00) | | |
420 (vp9.temporal_up_switch ? 0x08 : 0x00) | | |
421 (vp9.inter_pic_predicted ? 0x10 : 0x00); | |
422 } | |
423 | |
316 } // namespace webrtc | 424 } // namespace webrtc |
OLD | NEW |