Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1067)

Side by Side Diff: webrtc/common_types.h

Issue 2488833004: Reland of Issue 2434073003: Extract bitrate allocation ... (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/call/call_perf_tests.cc ('k') | webrtc/common_types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #ifndef WEBRTC_COMMON_TYPES_H_ 11 #ifndef WEBRTC_COMMON_TYPES_H_
12 #define WEBRTC_COMMON_TYPES_H_ 12 #define WEBRTC_COMMON_TYPES_H_
13 13
14 #include <assert.h> 14 #include <assert.h>
15 #include <stddef.h> 15 #include <stddef.h>
16 #include <string.h> 16 #include <string.h>
17 17
18 #include <string> 18 #include <string>
19 #include <vector> 19 #include <vector>
20 20
21 #include "webrtc/base/optional.h"
21 #include "webrtc/common_video/rotation.h" 22 #include "webrtc/common_video/rotation.h"
22 #include "webrtc/typedefs.h" 23 #include "webrtc/typedefs.h"
23 24
24 #if defined(_MSC_VER) 25 #if defined(_MSC_VER)
25 // Disable "new behavior: elements of array will be default initialized" 26 // Disable "new behavior: elements of array will be default initialized"
26 // warning. Affects OverUseDetectorOptions. 27 // warning. Affects OverUseDetectorOptions.
27 #pragma warning(disable : 4351) 28 #pragma warning(disable : 4351)
28 #endif 29 #endif
29 30
30 #if defined(WEBRTC_EXPORT) 31 #if defined(WEBRTC_EXPORT)
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 bool pictureLossIndicationOn; 516 bool pictureLossIndicationOn;
516 bool feedbackModeOn; 517 bool feedbackModeOn;
517 VideoCodecComplexity complexity; 518 VideoCodecComplexity complexity;
518 VP8ResilienceMode resilience; 519 VP8ResilienceMode resilience;
519 unsigned char numberOfTemporalLayers; 520 unsigned char numberOfTemporalLayers;
520 bool denoisingOn; 521 bool denoisingOn;
521 bool errorConcealmentOn; 522 bool errorConcealmentOn;
522 bool automaticResizeOn; 523 bool automaticResizeOn;
523 bool frameDroppingOn; 524 bool frameDroppingOn;
524 int keyFrameInterval; 525 int keyFrameInterval;
525 const TemporalLayersFactory* tl_factory; 526 TemporalLayersFactory* tl_factory;
526 }; 527 };
527 528
528 // VP9 specific. 529 // VP9 specific.
529 struct VideoCodecVP9 { 530 struct VideoCodecVP9 {
530 VideoCodecComplexity complexity; 531 VideoCodecComplexity complexity;
531 int resilience; 532 int resilience;
532 unsigned char numberOfTemporalLayers; 533 unsigned char numberOfTemporalLayers;
533 bool denoisingOn; 534 bool denoisingOn;
534 bool frameDroppingOn; 535 bool frameDroppingOn;
535 int keyFrameInterval; 536 int keyFrameInterval;
(...skipping 20 matching lines...) Expand all
556 kVideoCodecVP9, 557 kVideoCodecVP9,
557 kVideoCodecH264, 558 kVideoCodecH264,
558 kVideoCodecI420, 559 kVideoCodecI420,
559 kVideoCodecRED, 560 kVideoCodecRED,
560 kVideoCodecULPFEC, 561 kVideoCodecULPFEC,
561 kVideoCodecFlexfec, 562 kVideoCodecFlexfec,
562 kVideoCodecGeneric, 563 kVideoCodecGeneric,
563 kVideoCodecUnknown 564 kVideoCodecUnknown
564 }; 565 };
565 566
567 // Translates from name of codec to codec type and vice versa.
568 rtc::Optional<std::string> CodecTypeToPayloadName(VideoCodecType type);
569 rtc::Optional<VideoCodecType> PayloadNameToCodecType(const std::string& name);
570
566 union VideoCodecUnion { 571 union VideoCodecUnion {
567 VideoCodecVP8 VP8; 572 VideoCodecVP8 VP8;
568 VideoCodecVP9 VP9; 573 VideoCodecVP9 VP9;
569 VideoCodecH264 H264; 574 VideoCodecH264 H264;
570 }; 575 };
571 576
572 // Simulcast is when the same stream is encoded multiple times with different 577 // Simulcast is when the same stream is encoded multiple times with different
573 // settings such as resolution. 578 // settings such as resolution.
574 struct SimulcastStream { 579 struct SimulcastStream {
575 unsigned short width; 580 unsigned short width;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 const VideoCodecVP9& VP9() const; 636 const VideoCodecVP9& VP9() const;
632 VideoCodecH264* H264(); 637 VideoCodecH264* H264();
633 const VideoCodecH264& H264() const; 638 const VideoCodecH264& H264() const;
634 639
635 private: 640 private:
636 // TODO(hta): Consider replacing the union with a pointer type. 641 // TODO(hta): Consider replacing the union with a pointer type.
637 // This will allow removing the VideoCodec* types from this file. 642 // This will allow removing the VideoCodec* types from this file.
638 VideoCodecUnion codec_specific_; 643 VideoCodecUnion codec_specific_;
639 }; 644 };
640 645
646 class BitrateAllocation {
647 public:
648 static const size_t kMaxBitrateBps;
649 BitrateAllocation();
650
651 bool SetBitrate(size_t spatial_index,
652 size_t temporal_index,
653 uint32_t bitrate_bps);
654
655 uint32_t GetBitrate(size_t spatial_index, size_t temporal_index) const;
656
657 // Get the sum of all the temporal layer for a specific spatial layer.
658 uint32_t GetSpatialLayerSum(size_t spatial_index) const;
659
660 uint32_t get_sum_bps() const { return sum_; } // Sum of all bitrates.
661 uint32_t get_sum_kbps() const { return (sum_ + 500) / 1000; }
662
663 inline bool operator==(const BitrateAllocation& other) const {
664 return memcmp(bitrates_, other.bitrates_, sizeof(bitrates_)) == 0;
665 }
666 inline bool operator!=(const BitrateAllocation& other) const {
667 return !(*this == other);
668 }
669
670 private:
671 uint32_t sum_;
672 uint32_t bitrates_[kMaxSpatialLayers][kMaxTemporalStreams];
673 };
674
641 // Bandwidth over-use detector options. These are used to drive 675 // Bandwidth over-use detector options. These are used to drive
642 // experimentation with bandwidth estimation parameters. 676 // experimentation with bandwidth estimation parameters.
643 // See modules/remote_bitrate_estimator/overuse_detector.h 677 // See modules/remote_bitrate_estimator/overuse_detector.h
644 struct OverUseDetectorOptions { 678 struct OverUseDetectorOptions {
645 OverUseDetectorOptions() 679 OverUseDetectorOptions()
646 : initial_slope(8.0 / 512.0), 680 : initial_slope(8.0 / 512.0),
647 initial_offset(0), 681 initial_offset(0),
648 initial_e(), 682 initial_e(),
649 initial_process_noise(), 683 initial_process_noise(),
650 initial_avg_noise(0.0), 684 initial_avg_noise(0.0),
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 enum class RtcpMode { kOff, kCompound, kReducedSize }; 871 enum class RtcpMode { kOff, kCompound, kReducedSize };
838 872
839 enum NetworkState { 873 enum NetworkState {
840 kNetworkUp, 874 kNetworkUp,
841 kNetworkDown, 875 kNetworkDown,
842 }; 876 };
843 877
844 } // namespace webrtc 878 } // namespace webrtc
845 879
846 #endif // WEBRTC_COMMON_TYPES_H_ 880 #endif // WEBRTC_COMMON_TYPES_H_
OLDNEW
« no previous file with comments | « webrtc/call/call_perf_tests.cc ('k') | webrtc/common_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698