OLD | NEW |
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 |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 // Negative |round_trip_time_ms| results is an error message and empty list | 746 // Negative |round_trip_time_ms| results is an error message and empty list |
747 // is returned. | 747 // is returned. |
748 // | 748 // |
749 virtual std::vector<uint16_t> GetNackList( | 749 virtual std::vector<uint16_t> GetNackList( |
750 int64_t round_trip_time_ms) const = 0; | 750 int64_t round_trip_time_ms) const = 0; |
751 | 751 |
752 virtual void GetDecodingCallStatistics( | 752 virtual void GetDecodingCallStatistics( |
753 AudioDecodingCallStats* call_stats) const = 0; | 753 AudioDecodingCallStats* call_stats) const = 0; |
754 }; | 754 }; |
755 | 755 |
756 class AudioEncoder; | |
757 class ReceiverInfo; | |
758 | |
759 class AudioCoding { | |
760 public: | |
761 struct Config { | |
762 Config(); | |
763 | |
764 AudioCodingModule::Config ToOldConfig() const { | |
765 AudioCodingModule::Config old_config; | |
766 old_config.id = 0; | |
767 old_config.neteq_config = neteq_config; | |
768 old_config.clock = clock; | |
769 return old_config; | |
770 } | |
771 | |
772 NetEq::Config neteq_config; | |
773 Clock* clock; | |
774 AudioPacketizationCallback* transport; | |
775 ACMVADCallback* vad_callback; | |
776 int initial_playout_delay_ms; | |
777 int playout_channels; | |
778 int playout_frequency_hz; | |
779 }; | |
780 | |
781 static AudioCoding* Create(const Config& config); | |
782 virtual ~AudioCoding() {}; | |
783 | |
784 // Registers a codec, specified by |send_codec|, as sending codec. | |
785 // This API can be called multiple times. The last codec registered overwrites | |
786 // the previous ones. Returns true if successful, false if not. | |
787 // | |
788 // Note: If a stereo codec is registered as send codec, VAD/DTX will | |
789 // automatically be turned off, since it is not supported for stereo sending. | |
790 virtual bool RegisterSendCodec(AudioEncoder* send_codec) = 0; | |
791 | |
792 // Temporary solution to be used during refactoring: | |
793 // |encoder_type| should be from the anonymous enum in acm2::ACMCodecDB. | |
794 virtual bool RegisterSendCodec(int encoder_type, | |
795 uint8_t payload_type, | |
796 int frame_size_samples = 0) = 0; | |
797 | |
798 // Returns the encoder object currently in use. This is the same as the | |
799 // codec that was registered in the latest call to RegisterSendCodec(). | |
800 virtual const AudioEncoder* GetSenderInfo() const = 0; | |
801 | |
802 // Temporary solution to be used during refactoring. | |
803 virtual const CodecInst* GetSenderCodecInst() = 0; | |
804 | |
805 // Adds 10 ms of raw (PCM) audio data to the encoder. If the sampling | |
806 // frequency of the audio does not match the sampling frequency of the | |
807 // current encoder, ACM will resample the audio. | |
808 // | |
809 // Return value: | |
810 // 0 successfully added the frame. | |
811 // -1 some error occurred and data is not added. | |
812 // < -1 to add the frame to the buffer n samples had to be | |
813 // overwritten, -n is the return value in this case. | |
814 // TODO(henrik.lundin): Make a better design for the return values. This one | |
815 // is just a copy of the old API. | |
816 virtual int Add10MsAudio(const AudioFrame& audio_frame) = 0; | |
817 | |
818 // Returns a combined info about the currently used decoder(s). | |
819 virtual const ReceiverInfo* GetReceiverInfo() const = 0; | |
820 | |
821 // Registers a codec, specified by |receive_codec|, as receiving codec. | |
822 // This API can be called multiple times. If registering with a payload type | |
823 // that was already registered in a previous call, the latest call will | |
824 // override previous calls. Returns true if successful, false if not. | |
825 virtual bool RegisterReceiveCodec(AudioDecoder* receive_codec) = 0; | |
826 | |
827 // Temporary solution: | |
828 // |decoder_type| should be from the anonymous enum in acm2::ACMCodecDB. | |
829 virtual bool RegisterReceiveCodec(int decoder_type, uint8_t payload_type) = 0; | |
830 | |
831 // The following two methods both inserts a new packet to the receiver. | |
832 // InsertPacket takes an RTP header input in |rtp_info|, while InsertPayload | |
833 // only requires a payload type and a timestamp. The latter assumes that the | |
834 // payloads come in the right order, and without any losses. In both cases, | |
835 // |incoming_payload| contains the RTP payload after the RTP header. Return | |
836 // true if successful, false if not. | |
837 virtual bool InsertPacket(const uint8_t* incoming_payload, | |
838 size_t payload_len_bytes, | |
839 const WebRtcRTPHeader& rtp_info) = 0; | |
840 | |
841 // TODO(henrik.lundin): Remove this method? | |
842 virtual bool InsertPayload(const uint8_t* incoming_payload, | |
843 size_t payload_len_byte, | |
844 uint8_t payload_type, | |
845 uint32_t timestamp) = 0; | |
846 | |
847 // These two methods set a minimum and maximum jitter buffer delay in | |
848 // milliseconds. The pupose is mainly to adjust the delay to synchronize | |
849 // audio and video. The preferred jitter buffer size, computed by NetEq based | |
850 // on the current channel conditions, is clamped from below and above by these | |
851 // two methods. The given delay limits must be non-negative, less than | |
852 // 10000 ms, and the minimum must be strictly smaller than the maximum. | |
853 // Further, the maximum must be at lest one frame duration. If these | |
854 // conditions are not met, false is returned. Giving the value 0 effectively | |
855 // unsets the minimum or maximum delay limits. | |
856 // Note that calling these methods is optional. If not called, NetEq will | |
857 // determine the optimal buffer size based on the network conditions. | |
858 virtual bool SetMinimumPlayoutDelay(int time_ms) = 0; | |
859 | |
860 virtual bool SetMaximumPlayoutDelay(int time_ms) = 0; | |
861 | |
862 // Returns the current value of the jitter buffer's preferred latency. This | |
863 // is computed based on inter-arrival times and playout mode of NetEq. The | |
864 // actual target delay is this value clamped from below and above by the | |
865 // values specified through SetMinimumPlayoutDelay() and | |
866 // SetMaximumPlayoutDelay(), respectively, if provided. | |
867 // TODO(henrik.lundin) Rename to PreferredDelayMs? | |
868 virtual int LeastRequiredDelayMs() const = 0; | |
869 | |
870 // The send timestamp of an RTP packet is associated with the decoded | |
871 // audio of the packet in question. This function returns the timestamp of | |
872 // the latest audio delivered by Get10MsAudio(). Returns false if no timestamp | |
873 // can be provided, true otherwise. | |
874 virtual bool PlayoutTimestamp(uint32_t* timestamp) = 0; | |
875 | |
876 // Delivers 10 ms of audio in |audio_frame|. Returns true if successful, | |
877 // false otherwise. | |
878 virtual bool Get10MsAudio(AudioFrame* audio_frame) = 0; | |
879 | |
880 // Returns the network statistics. Note that the internal statistics of NetEq | |
881 // are reset by this call. Returns true if successful, false otherwise. | |
882 virtual bool GetNetworkStatistics(NetworkStatistics* network_statistics) = 0; | |
883 | |
884 // Enables NACK and sets the maximum size of the NACK list. If NACK is already | |
885 // enabled then the maximum NACK list size is modified accordingly. Returns | |
886 // true if successful, false otherwise. | |
887 // | |
888 // If the sequence number of last received packet is N, the sequence numbers | |
889 // of NACK list are in the range of [N - |max_nack_list_size|, N). | |
890 // | |
891 // |max_nack_list_size| should be positive and less than or equal to | |
892 // |Nack::kNackListSizeLimit|. | |
893 virtual bool EnableNack(size_t max_nack_list_size) = 0; | |
894 | |
895 // Disables NACK. | |
896 virtual void DisableNack() = 0; | |
897 | |
898 | |
899 // Temporary solution to be used during refactoring. | |
900 // If DTX is enabled and the codec does not have internal DTX/VAD | |
901 // WebRtc VAD will be automatically enabled and |enable_vad| is ignored. | |
902 // | |
903 // If DTX is disabled but VAD is enabled no DTX packets are sent, | |
904 // regardless of whether the codec has internal DTX/VAD or not. In this | |
905 // case, WebRtc VAD is running to label frames as active/in-active. | |
906 // | |
907 // NOTE! VAD/DTX is not supported when sending stereo. | |
908 // | |
909 // Return true if successful, false otherwise. | |
910 virtual bool SetVad(bool enable_dtx, | |
911 bool enable_vad, | |
912 ACMVADMode vad_mode) = 0; | |
913 | |
914 // Returns a list of packets to request retransmission of. | |
915 // |round_trip_time_ms| is an estimate of the round-trip-time (in | |
916 // milliseconds). Missing packets which will be decoded sooner than the | |
917 // round-trip-time (with respect to the time this API is called) will not be | |
918 // included in the list. | |
919 // |round_trip_time_ms| must be non-negative. | |
920 virtual std::vector<uint16_t> GetNackList(int round_trip_time_ms) const = 0; | |
921 | |
922 // Returns the timing statistics for calls to Get10MsAudio. | |
923 virtual void GetDecodingCallStatistics( | |
924 AudioDecodingCallStats* call_stats) const = 0; | |
925 }; | |
926 | |
927 } // namespace webrtc | 756 } // namespace webrtc |
928 | 757 |
929 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H_ | 758 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H_ |
OLD | NEW |