CNLiveChatVoiceMessage.h
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// CNLiveChatVoiceMessage.h
// CNLiveChatManagerSDKDemo
//
// Created by cnliveJunBo on 17/7/12.
// Copyright © 2017年 cnlive. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CNLiveChatStatusDefine.h"
#import "CNLiveChatUserInfo.h"
@interface CNLiveChatVoiceMessage : NSObject
/*!
wav格式的音频数据
*/
@property(nonatomic, strong) NSData *wavAudioData;
/*!
语音消息的时长
*/
@property(nonatomic, assign) long duration;
/*!
语音消息的附加信息
*/
@property(nonatomic, strong) NSString *extra;
// * 基础属性 *
/**
会话类型(私聊 / 聊天室)
*/
@property (nonatomic, assign) CNLiveConversationType conversationType;
/**
目标ID(消息来自聊天室的ID / 接收者ID)
*/
@property (nonatomic, copy) NSString *targetId;
/**
消息ID(本地存储的消息的唯一值(数据库索引唯一值))
*/
@property (nonatomic, copy) NSString *messageId;
/**
发送者的用户信息(userId, name, portraitUri)
*/
@property (nonatomic, strong) CNLiveChatUserInfo *userInfo;
/*!
初始化语音消息
@param audioData wav格式的音频数据
@param duration 语音消息的时长(单位:秒)
@return 语音消息对象
@discussion
如果您不是使用IMKit中的录音功能,则在初始化语音消息的时候,需要确保以下几点。
1. audioData必须是单声道的wav格式音频数据;
2. audioData的采样率必须是8000Hz,采样位数(精度)必须为16位。
您可以参考的录音参数:
NSDictionary *settings = @{AVFormatIDKey: @(kAudioFormatLinearPCM),
AVSampleRateKey: @8000.00f,
AVNumberOfChannelsKey: @1,
AVLinearPCMBitDepthKey: @16,
AVLinearPCMIsNonInterleaved: @NO,
AVLinearPCMIsFloatKey: @NO,
AVLinearPC'MIsBigEndianKey: @NO};
*/
+ (instancetype)messageWithAudio:(NSData *)audioData duration:(long)duration;
@end