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

Side by Side Diff: webrtc/common_types.h

Issue 2510583002: Reland #2 of Issue 2434073003: Extract bitrate allocation ... (Closed)
Patch Set: Addressed comments 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 VideoCodecH264* H264(); 637 VideoCodecH264* H264();
633 const VideoCodecH264& H264() const; 638 const VideoCodecH264& H264() const;
634 639
635 // This variable will be declared private and renamed to codec_specific_ 640 // This variable will be declared private and renamed to codec_specific_
636 // once Chromium is not accessing it. 641 // once Chromium is not accessing it.
637 // TODO(hta): Consider replacing the union with a pointer type. 642 // TODO(hta): Consider replacing the union with a pointer type.
638 // This will allow removing the VideoCodec* types from this file. 643 // This will allow removing the VideoCodec* types from this file.
639 VideoCodecUnion codecSpecific; 644 VideoCodecUnion codecSpecific;
640 }; 645 };
641 646
647 class BitrateAllocation {
648 public:
649 static const uint32_t kMaxBitrateBps;
650 BitrateAllocation();
651
652 bool SetBitrate(size_t spatial_index,
653 size_t temporal_index,
654 uint32_t bitrate_bps);
655
656 uint32_t GetBitrate(size_t spatial_index, size_t temporal_index) const;
657
658 // Get the sum of all the temporal layer for a specific spatial layer.
659 uint32_t GetSpatialLayerSum(size_t spatial_index) const;
660
661 uint32_t get_sum_bps() const { return sum_; } // Sum of all bitrates.
662 uint32_t get_sum_kbps() const { return (sum_ + 500) / 1000; }
663
664 inline bool operator==(const BitrateAllocation& other) const {
665 return memcmp(bitrates_, other.bitrates_, sizeof(bitrates_)) == 0;
666 }
667 inline bool operator!=(const BitrateAllocation& other) const {
668 return !(*this == other);
669 }
670
671 private:
672 uint32_t sum_;
673 uint32_t bitrates_[kMaxSpatialLayers][kMaxTemporalStreams];
674 };
675
642 // Bandwidth over-use detector options. These are used to drive 676 // Bandwidth over-use detector options. These are used to drive
643 // experimentation with bandwidth estimation parameters. 677 // experimentation with bandwidth estimation parameters.
644 // See modules/remote_bitrate_estimator/overuse_detector.h 678 // See modules/remote_bitrate_estimator/overuse_detector.h
645 struct OverUseDetectorOptions { 679 struct OverUseDetectorOptions {
646 OverUseDetectorOptions() 680 OverUseDetectorOptions()
647 : initial_slope(8.0 / 512.0), 681 : initial_slope(8.0 / 512.0),
648 initial_offset(0), 682 initial_offset(0),
649 initial_e(), 683 initial_e(),
650 initial_process_noise(), 684 initial_process_noise(),
651 initial_avg_noise(0.0), 685 initial_avg_noise(0.0),
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 enum class RtcpMode { kOff, kCompound, kReducedSize }; 872 enum class RtcpMode { kOff, kCompound, kReducedSize };
839 873
840 enum NetworkState { 874 enum NetworkState {
841 kNetworkUp, 875 kNetworkUp,
842 kNetworkDown, 876 kNetworkDown,
843 }; 877 };
844 878
845 } // namespace webrtc 879 } // namespace webrtc
846 880
847 #endif // WEBRTC_COMMON_TYPES_H_ 881 #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