blob: f6829cace5c629e55a2ec9cd5a471cd49a55de89 [file] [log] [blame]
Stefan Holmerf7044682018-07-17 10:16:41 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef CALL_RTP_PAYLOAD_PARAMS_H_
12#define CALL_RTP_PAYLOAD_PARAMS_H_
13
14#include <map>
15#include <vector>
16
17#include "api/video_codecs/video_encoder.h"
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020018#include "call/rtp_config.h"
Stefan Holmerf7044682018-07-17 10:16:41 +020019#include "common_types.h" // NOLINT(build/include)
philipelbf2b6202018-08-27 14:33:18 +020020#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h"
Stefan Holmerf7044682018-07-17 10:16:41 +020021#include "modules/rtp_rtcp/source/rtp_video_header.h"
22
23namespace webrtc {
24
25class RTPFragmentationHeader;
26class RtpRtcp;
27
Stefan Holmerf7044682018-07-17 10:16:41 +020028// State for setting picture id and tl0 pic idx, for VP8 and VP9
29// TODO(nisse): Make these properties not codec specific.
30class RtpPayloadParams final {
31 public:
32 RtpPayloadParams(const uint32_t ssrc, const RtpPayloadState* state);
philipelbf2b6202018-08-27 14:33:18 +020033 RtpPayloadParams(const RtpPayloadParams& other);
Stefan Holmerf7044682018-07-17 10:16:41 +020034 ~RtpPayloadParams();
35
philipelbf2b6202018-08-27 14:33:18 +020036 RTPVideoHeader GetRtpVideoHeader(const EncodedImage& image,
37 const CodecSpecificInfo* codec_specific_info,
38 int64_t shared_frame_id);
Stefan Holmerf7044682018-07-17 10:16:41 +020039
40 uint32_t ssrc() const;
41
42 RtpPayloadState state() const;
43
44 private:
philipelbf2b6202018-08-27 14:33:18 +020045 void SetCodecSpecific(RTPVideoHeader* rtp_video_header,
46 bool first_frame_in_picture);
47 void SetGeneric(int64_t frame_id,
48 bool is_keyframe,
49 RTPVideoHeader* rtp_video_header);
Stefan Holmerf7044682018-07-17 10:16:41 +020050
philipelbf2b6202018-08-27 14:33:18 +020051 void Vp8ToGeneric(int64_t shared_frame_id,
52 bool is_keyframe,
53 RTPVideoHeader* rtp_video_header);
54
55 // Holds the last shared frame id for a given (spatial, temporal) layer.
56 std::array<std::array<int64_t, RtpGenericFrameDescriptor::kMaxTemporalLayers>,
57 RtpGenericFrameDescriptor::kMaxSpatialLayers>
58 last_shared_frame_id_;
Stefan Holmerf7044682018-07-17 10:16:41 +020059 const uint32_t ssrc_;
60 RtpPayloadState state_;
philipelbf2b6202018-08-27 14:33:18 +020061
62 const bool generic_picture_id_experiment_;
philipel569397f2018-09-26 12:25:31 +020063 const bool generic_descriptor_experiment_;
Stefan Holmerf7044682018-07-17 10:16:41 +020064};
65} // namespace webrtc
66#endif // CALL_RTP_PAYLOAD_PARAMS_H_