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

Side by Side Diff: media/cast/audio_receiver/audio_decoder.h

Issue 74133002: Cast: Removed unnecessary ref counters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODO Created 7 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 | « no previous file | media/cast/audio_receiver/audio_decoder.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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ 5 #ifndef MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_
6 #define MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ 6 #define MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_
7 7
8 #include "base/atomicops.h"
8 #include "base/callback.h" 9 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "media/cast/cast_config.h" 10 #include "media/cast/cast_config.h"
11 #include "media/cast/rtp_common/rtp_defines.h" 11 #include "media/cast/rtp_common/rtp_defines.h"
12 12
13 namespace webrtc { 13 namespace webrtc {
14 class AudioCodingModule; 14 class AudioCodingModule;
15 } 15 }
16 16
17 namespace media { 17 namespace media {
18 namespace cast { 18 namespace cast {
19 19
20 // Thread safe class. 20 // Thread safe class.
21 class AudioDecoder : public base::RefCountedThreadSafe<AudioDecoder> { 21 class AudioDecoder {
22 public: 22 public:
23 explicit AudioDecoder(const AudioReceiverConfig& audio_config); 23 explicit AudioDecoder(const AudioReceiverConfig& audio_config);
24 virtual ~AudioDecoder();
24 25
25 // Extract a raw audio frame from the decoder. 26 // Extract a raw audio frame from the decoder.
26 // Set the number of desired 10ms blocks and frequency. 27 // Set the number of desired 10ms blocks and frequency.
27 // Should be called from the cast audio decoder thread; however that is not 28 // Should be called from the cast audio decoder thread; however that is not
28 // required. 29 // required.
29 bool GetRawAudioFrame(int number_of_10ms_blocks, 30 bool GetRawAudioFrame(int number_of_10ms_blocks,
30 int desired_frequency, 31 int desired_frequency,
31 PcmAudioFrame* audio_frame, 32 PcmAudioFrame* audio_frame,
32 uint32* rtp_timestamp); 33 uint32* rtp_timestamp);
33 34
34 // Insert an RTP packet to the decoder. 35 // Insert an RTP packet to the decoder.
35 // Should be called from the main cast thread; however that is not required. 36 // Should be called from the main cast thread; however that is not required.
36 void IncomingParsedRtpPacket(const uint8* payload_data, 37 void IncomingParsedRtpPacket(const uint8* payload_data,
37 size_t payload_size, 38 size_t payload_size,
38 const RtpCastHeader& rtp_header); 39 const RtpCastHeader& rtp_header);
39 40
40 protected:
41 virtual ~AudioDecoder();
42
43 private: 41 private:
44 friend class base::RefCountedThreadSafe<AudioDecoder>; 42 // The webrtc AudioCodingModule is threadsafe.
45
46 scoped_ptr<webrtc::AudioCodingModule> audio_decoder_; 43 scoped_ptr<webrtc::AudioCodingModule> audio_decoder_;
47 bool have_received_packets_; 44 // TODO(pwestin): Refactor to avoid this. Call IncomingParsedRtpPacket from
45 // audio decoder thread that way this class does not have to be thread safe.
46 base::subtle::Atomic32 have_received_packets_;
Alpha Left Google 2013/11/18 22:01:14 Is there a difference in terms of performance usin
pwestin 2013/11/22 19:16:29 I doubt there is a measurable difference for this
48 47
49 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); 48 DISALLOW_COPY_AND_ASSIGN(AudioDecoder);
50 }; 49 };
51 50
52 } // namespace cast 51 } // namespace cast
53 } // namespace media 52 } // namespace media
54 53
55 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ 54 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | media/cast/audio_receiver/audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698