恢复master版本,提交不影响master代码,以新增对讲新分支
This commit is contained in:
parent
73e8211165
commit
3103071653
@ -243,11 +243,75 @@
|
||||
}
|
||||
}
|
||||
- (void)RefImg:(NSData *)data{
|
||||
NSString *getStr = [self convertDataToHexStr:data];
|
||||
NSLog(@"111得到的十六进制图像数据为:%@", getStr);
|
||||
|
||||
NSData *binaryData = [self dataFromHexString:getStr];
|
||||
// 将NSData转换为二进制数组
|
||||
const uint8_t *bytes = (const uint8_t *)[binaryData bytes];
|
||||
NSUInteger length = [binaryData length];
|
||||
NSMutableArray *binaryArray = [NSMutableArray array];
|
||||
for (NSUInteger i = 0; i < length; i++) {
|
||||
[binaryArray addObject:@(bytes[i])];
|
||||
}
|
||||
NSLog(@"222得到的二进制图像数据为:%@", binaryArray);
|
||||
|
||||
UIImage *image = [UIImage imageWithData: data];
|
||||
//self.playerImage = [[UIImageView alloc] initWithImage:image];
|
||||
[self.playerImage setImage:image];
|
||||
}
|
||||
|
||||
//将NSData转换成十六进制的字符串则可使用如下方式:
|
||||
- (NSString *)convertDataToHexStr:(NSData *)data {
|
||||
if (!data || [data length] == 0) {
|
||||
return @"";
|
||||
}
|
||||
NSMutableString *string = [[NSMutableString alloc] initWithCapacity:[data length]];
|
||||
|
||||
[data enumerateByteRangesUsingBlock:^(const void *bytes, NSRange byteRange, BOOL *stop) {
|
||||
unsigned char *dataBytes = (unsigned char*)bytes;
|
||||
for (NSInteger i = 0; i < byteRange.length; i++) {
|
||||
NSString *hexStr = [NSString stringWithFormat:@"%x", (dataBytes[i]) & 0xff];
|
||||
if ([hexStr length] == 2) {
|
||||
[string appendString:hexStr];
|
||||
} else {
|
||||
[string appendFormat:@"0%@", hexStr];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
//将十六进制字符串转换为二进制数据
|
||||
- (NSData *)dataFromHexString:(NSString *)hexString {
|
||||
// 去除字符串中的空格和换行符
|
||||
NSString *cleanedString = [hexString stringByReplacingOccurrencesOfString:@" " withString:@""];
|
||||
cleanedString = [cleanedString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
|
||||
|
||||
// 检查字符串长度是否为偶数
|
||||
if (cleanedString.length % 2 != 0) {
|
||||
// 如果长度为奇数,可以根据需要选择在字符串前面添加或去除一个字符
|
||||
// 例如,你可以选择在前面添加一个零,或者去除最后一个字符
|
||||
// cleanedString = [@"0" stringByAppendingString:cleanedString];
|
||||
// 或者
|
||||
// cleanedString = [cleanedString substringToIndex:cleanedString.length - 1];
|
||||
}
|
||||
|
||||
// 使用一个循环将每两个字符转换为一个字节
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
for (NSInteger i = 0; i < cleanedString.length; i += 2) {
|
||||
NSString *byteString = [cleanedString substringWithRange:NSMakeRange(i, 2)];
|
||||
NSScanner *scanner = [NSScanner scannerWithString:byteString];
|
||||
unsigned int byteValue;
|
||||
[scanner scanHexInt:&byteValue];
|
||||
uint8_t byte = (uint8_t)byteValue;
|
||||
[data appendBytes:&byte length:1];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
|
||||
@ -47,4 +47,6 @@
|
||||
+ (NSString *)NSdata2String:(NSData *)data;
|
||||
+ (NSData *)AES128_Encrypt:(NSString *)key encryptData:(NSData *)data;
|
||||
+ (NSData *)AES128_Decrypt:(NSString *)key encryptData:(NSData *)data;
|
||||
+ (NSString *)convertDataToHexStr:(NSData *)data;//将NSData转换成十六进制数据
|
||||
+ (NSData *)dataFromHexString:(NSString *)hexString;//将十六进制字符串转换为二进制数据
|
||||
@end
|
||||
|
||||
@ -353,4 +353,54 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
//将NSData转换成十六进制的字符串则可使用如下方式:
|
||||
+ (NSString *)convertDataToHexStr:(NSData *)data {
|
||||
if (!data || [data length] == 0) {
|
||||
return @"";
|
||||
}
|
||||
NSMutableString *string = [[NSMutableString alloc] initWithCapacity:[data length]];
|
||||
|
||||
[data enumerateByteRangesUsingBlock:^(const void *bytes, NSRange byteRange, BOOL *stop) {
|
||||
unsigned char *dataBytes = (unsigned char*)bytes;
|
||||
for (NSInteger i = 0; i < byteRange.length; i++) {
|
||||
NSString *hexStr = [NSString stringWithFormat:@"%x", (dataBytes[i]) & 0xff];
|
||||
if ([hexStr length] == 2) {
|
||||
[string appendString:hexStr];
|
||||
} else {
|
||||
[string appendFormat:@"0%@", hexStr];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
//将十六进制字符串转换为二进制数据
|
||||
+ (NSData *)dataFromHexString:(NSString *)hexString {
|
||||
// 去除字符串中的空格和换行符
|
||||
NSString *cleanedString = [hexString stringByReplacingOccurrencesOfString:@" " withString:@""];
|
||||
cleanedString = [cleanedString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
|
||||
|
||||
// 检查字符串长度是否为偶数
|
||||
if (cleanedString.length % 2 != 0) {
|
||||
// 如果长度为奇数,可以根据需要选择在字符串前面添加或去除一个字符
|
||||
// 例如,你可以选择在前面添加一个零,或者去除最后一个字符
|
||||
// cleanedString = [@"0" stringByAppendingString:cleanedString];
|
||||
// 或者
|
||||
// cleanedString = [cleanedString substringToIndex:cleanedString.length - 1];
|
||||
}
|
||||
|
||||
// 使用一个循环将每两个字符转换为一个字节
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
for (NSInteger i = 0; i < cleanedString.length; i += 2) {
|
||||
NSString *byteString = [cleanedString substringWithRange:NSMakeRange(i, 2)];
|
||||
NSScanner *scanner = [NSScanner scannerWithString:byteString];
|
||||
unsigned int byteValue;
|
||||
[scanner scanHexInt:&byteValue];
|
||||
uint8_t byte = (uint8_t)byteValue;
|
||||
[data appendBytes:&byte length:1];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@end
|
||||
|
||||
@ -40,12 +40,13 @@ static bool isAudioStop;
|
||||
//回调 每当一组音频数据读取完毕之后会自动触发回调方法,读取下一帧数据
|
||||
void buffer_callback(void *inUserData, AudioQueueRef q, AudioQueueBufferRef buf) {
|
||||
//__bridge
|
||||
//NSLog(@"buffer_callback");
|
||||
// NSLog(@"333buffer_callback");
|
||||
playAudio* player = (__bridge playAudio*)inUserData;
|
||||
[player audioQueueOutputWithQueue:q queueBuffer:buf];
|
||||
}
|
||||
|
||||
- (short)G711Decode_u_law_2_linear:(Byte)b {
|
||||
// NSLog(@"444G711Decode_u_law_2_linear");
|
||||
//u律 8126
|
||||
short t;
|
||||
b = ~b;
|
||||
@ -80,7 +81,7 @@ void buffer_callback(void *inUserData, AudioQueueRef q, AudioQueueBufferRef buf)
|
||||
}
|
||||
|
||||
- (void)audioQueueOutputWithQueue:(AudioQueueRef)q queueBuffer:(AudioQueueBufferRef)buf {
|
||||
//NSLog(@"audioQueueOutputWithQueue: _AudiodecodeType = %d", _AudiodecodeType);
|
||||
// NSLog(@"222audioQueueOutputWithQueue: _AudiodecodeType = %d", _AudiodecodeType);
|
||||
if (_AudiodecodeType == k711) {
|
||||
buf->mAudioDataByteSize = BYTES_PER_SAMPLES;
|
||||
short *b = buf->mAudioData;
|
||||
@ -113,7 +114,7 @@ void buffer_callback(void *inUserData, AudioQueueRef q, AudioQueueBufferRef buf)
|
||||
}
|
||||
|
||||
- (void)AudioPlayStartWithMode:(int)mod {
|
||||
NSLog(@"AudioPlayStartWithMode mod = %d", mod);
|
||||
// NSLog(@"111AudioPlayStartWithMode mod = %d", mod);
|
||||
app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
|
||||
int channels = 1;//default 1
|
||||
Abuf_p = 0;
|
||||
|
||||
@ -803,7 +803,7 @@ static char cnt;
|
||||
}
|
||||
|
||||
|
||||
- (void)getImgData:(Byte *)bb len:(int)l {
|
||||
- (void)getImgData:(Byte *)bb len:(int)length123 {
|
||||
//[player1 getImg:bb len:l];
|
||||
}
|
||||
|
||||
@ -822,6 +822,21 @@ static char cnt;
|
||||
// memcpy(audio.Abuf+160*pp+1, bb+9+12, 159); //head 9byte | data 172byte() 数据
|
||||
// }
|
||||
//NSLog(@"音频数据");
|
||||
NSData *data1 = [[NSData alloc] initWithBytes:bb length:1000];
|
||||
// NSLog(@"音频111得到的data1数据为:%@", data1);
|
||||
|
||||
NSString *getStr = [Pub convertDataToHexStr:data1];
|
||||
NSLog(@"音频数据111得到的十六进制图像数据为:%@", getStr);
|
||||
|
||||
NSData *binaryData = [Pub dataFromHexString:getStr];
|
||||
// 将NSData转换为二进制数组
|
||||
const uint8_t *bytes = (const uint8_t *)[binaryData bytes];
|
||||
NSUInteger length = [binaryData length];
|
||||
NSMutableArray *binaryArray = [NSMutableArray array];
|
||||
for (NSUInteger i = 0; i < length; i++) {
|
||||
[binaryArray addObject:@(bytes[i])];
|
||||
}
|
||||
NSLog(@"音频数据222得到的二进制图像数据为:%@", binaryArray);
|
||||
if(status!=8 && status!=5)return;
|
||||
if(audio){
|
||||
//NSLog(@"getAVData %@",[Sformat Hex:[[NSData alloc] initWithBytes:bb length:len]]);
|
||||
@ -839,6 +854,7 @@ static char cnt;
|
||||
|
||||
}
|
||||
else{//视频数据
|
||||
NSData *data1 = [[NSData alloc] initWithBytes:bb length:60+32];
|
||||
BAGLEN = [Pub getShortFromByte:bb at:POS_blen + 2];
|
||||
iframe_index = [Pub getShortFromByte:bb at:POS_iframe_index];
|
||||
alen = [Pub getShortFromByte:bb at:POS_alen];
|
||||
@ -855,7 +871,7 @@ static char cnt;
|
||||
}
|
||||
iframe.bag_receive ++;
|
||||
memcpy(iframe.bb + BAGLEN*(bag_index-FIRSTINDEX), bb + POS_data, blen);
|
||||
|
||||
|
||||
if(iframe.bag_num == iframe.bag_receive){
|
||||
//NSLog(@"播放第%d帧",iframe.iframe_index);
|
||||
if([Pub getApp].callOut){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user