Skip to content

Commit bbe0d01

Browse files
committed
translate AudioStream into English
translate AudioStream into English
1 parent a661a76 commit bbe0d01

4 files changed

Lines changed: 14 additions & 18 deletions

File tree

‎Live/src/main/cpp/AudioStream.cpp‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,22 @@ void AudioStream::setAudioCallback(AudioCallback audioCallback) {
2020
}
2121

2222
void AudioStream::setAudioEncInfo(int samplesInHZ, int channels) {
23-
//打开编码器
2423
mChannels = channels;
25-
//一次最大能输入编码器的样本数量 (一个样本是16位 2字节)
26-
//编码后的最大字节数
24+
//open faac encoder
2725
audioCodec = faacEncOpen(static_cast<unsigned long>(samplesInHZ),
2826
static_cast<unsigned int>(channels),
2927
&inputSamples,
3028
&maxOutputBytes);
3129

32-
//设置编码器参数
30+
//set encoder params
3331
faacEncConfigurationPtr config = faacEncGetCurrentConfiguration(audioCodec);
34-
//指定为 mpeg4 标准
3532
config->mpegVersion = MPEG4;
36-
//lc 标准
3733
config->aacObjectType = LOW;
38-
//16位
3934
config->inputFormat = FAAC_INPUT_16BIT;
40-
// 编码出原始数据
4135
config->outputFormat = 0;
4236
faacEncSetConfiguration(audioCodec, config);
4337

44-
//输出缓冲区 编码后的数据 用这个缓冲区来保存
38+
//output buffer
4539
buffer = new u_char[maxOutputBytes];
4640
}
4741

@@ -56,7 +50,7 @@ RTMPPacket *AudioStream::getAudioTag() {
5650
int bodySize = static_cast<int>(2 + len);
5751
RTMPPacket *packet = new RTMPPacket;
5852
RTMPPacket_Alloc(packet, bodySize);
59-
//双声道
53+
//channel layout: stereo
6054
packet->m_body[0] = 0xAF;
6155
if (mChannels == 1) {
6256
packet->m_body[0] = 0xAE;
@@ -74,7 +68,7 @@ RTMPPacket *AudioStream::getAudioTag() {
7468
}
7569

7670
void AudioStream::encodeData(int8_t *data) {
77-
//返回编码后数据字节的长度
71+
//encode a frame, and return encoded len
7872
int byteLen = faacEncEncode(audioCodec, reinterpret_cast<int32_t *>(data),
7973
static_cast<unsigned int>(inputSamples),
8074
buffer,
@@ -83,7 +77,7 @@ void AudioStream::encodeData(int8_t *data) {
8377
int bodySize = 2 + byteLen;
8478
RTMPPacket *packet = new RTMPPacket;
8579
RTMPPacket_Alloc(packet, bodySize);
86-
//双声道
80+
//stereo
8781
packet->m_body[0] = 0xAF;
8882
if (mChannels == 1) {
8983
packet->m_body[0] = 0xAE;

‎Live/src/main/cpp/AudioStream.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class AudioStream {
2222

2323
void encodeData(int8_t *data);
2424

25-
RTMPPacket* getAudioTag();
25+
RTMPPacket *getAudioTag();
26+
2627
private:
2728
AudioCallback audioCallback;
2829
int mChannels;

‎Live/src/main/cpp/VideoStream.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
#include "include/x264/x264.h"
99

1010
class VideoStream {
11-
typedef void (*VideoCallback)(RTMPPacket* packet);
11+
typedef void (*VideoCallback)(RTMPPacket *packet);
12+
1213
public:
1314
VideoStream();
1415

1516
~VideoStream();
1617

17-
//创建x264编码器
1818
void setVideoEncInfo(int width, int height, int fps, int bitrate);
1919

2020
void encodeData(int8_t *data);
@@ -35,6 +35,7 @@ class VideoStream {
3535
int ySize;
3636
int uvSize;
3737
VideoCallback videoCallback;
38+
3839
void sendSpsPps(uint8_t *sps, uint8_t *pps, int sps_len, int pps_len);
3940

4041
void sendFrame(int type, uint8_t *payload, int i_payload);

‎Live/src/main/cpp/safe_queue.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SafeQueue {
3737

3838
}
3939

40-
void push( T new_value) {
40+
void push(T new_value) {
4141
#ifdef C11
4242
//锁 和智能指针原理类似,自动释放
4343
lock_guard<mutex> lk(mt);
@@ -50,7 +50,7 @@ class SafeQueue {
5050
if (work) {
5151
q.push(new_value);
5252
pthread_cond_signal(&cond);
53-
}else{
53+
} else {
5454
releaseCallback(new_value);
5555
}
5656
pthread_mutex_unlock(&mutex);
@@ -59,7 +59,7 @@ class SafeQueue {
5959
}
6060

6161

62-
int pop(T& value) {
62+
int pop(T &value) {
6363
int ret = 0;
6464
#ifdef C11
6565
//占用空间相对lock_guard 更大一点且相对更慢一点,但是配合条件必须使用它,更灵活

0 commit comments

Comments
 (0)