New file |
| | |
| | | // |
| | | // AoyouSDK.h |
| | | // Aoyou1_0 |
| | | // |
| | | // Created by wanglu on 2018/11/8. |
| | | // Copyright © 2018年 Joker_chen. All rights reserved. |
| | | // |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import <UIKit/UIKit.h> |
| | | NS_ASSUME_NONNULL_BEGIN |
| | | |
| | | @interface AoyouSDK : NSObject |
| | | |
| | | |
| | | |
| | | /** |
| | | 加载登录页面 |
| | | |
| | | @param successBlock 登录成功回调 |
| | | @param failedBlock 失败回调 |
| | | * 状态码描述 |
| | | code = -1 : 用户名不能为空 |
| | | code = -2 : 用户名长度不正确 |
| | | code = -3 : 没有注册设备来源 |
| | | code = -4 : 密钥不对 |
| | | code = -5 : 渠道ID不能为空 |
| | | code = -6 : 账号不存在或者密码不正确 |
| | | code = -7 : 游戏ID不能为空 |
| | | code = -8 : 注册失败 |
| | | code = 501: 网络连接失败 |
| | | */ |
| | | + (void)loadLoginingVCResultSuccess:(void(^)(NSString *loginTime ,NSString *userName ,NSString *sign))successBlock failed:(void(^)(NSInteger code, NSString *message)) failedBlock; |
| | | |
| | | /** |
| | | * 加载FQ页面 |
| | | * |
| | | * @param roleid 角色id |
| | | * @param ServiceID 服务器id |
| | | * @param mo FQ |
| | | * @param attach 扩展参数 |
| | | * @param name 产品名称 |
| | | * @param desc 产品说明 |
| | | * @param productId 苹果产品Id |
| | | * @param successBlock 成功回调 |
| | | * @param faildBlock 失败回调 |
| | | * 状态码描述 |
| | | code = -1 : 缺少参数,请重试 |
| | | code = -2 : 密钥不对 |
| | | code = -3 : 渠道ID不能为空 |
| | | code = -4 : 用户名不能为空 |
| | | code = -5 : 游戏ID不能为空 |
| | | code = -6 : 余额不足 |
| | | code = -7 : 内部服务器发生错误,请重试! |
| | | code = -8 : 没有回调地址,请通知我方配置 |
| | | code = -9 : 必须大于0 |
| | | |
| | | */ |
| | | + (void)loadToFQVCWithRoleid:(NSString*)roleid |
| | | mo:(NSString *)mo |
| | | serverid:(NSString*)ServiceID |
| | | productName:(NSString *)name |
| | | productDesc:(NSString *)desc |
| | | attach:(NSString *)attach |
| | | productId:(NSString *)productId |
| | | success:(void(^)(NSString *message,NSString *mon))successBlock faild:(void(^)(NSString *message,NSInteger code,NSString *mon))faildBlock; |
| | | |
| | | |
| | | /** |
| | | * 退出登陆 |
| | | */ |
| | | + (void)LoginOut; |
| | | |
| | | |
| | | /** |
| | | * 设置用户信息---支持改名(option) |
| | | * |
| | | * @param roleId 角色id 必须 |
| | | * @param roleName 角色名(支持改名) 必须 |
| | | * @param Level 角色等级 必须 |
| | | * @param zoneId 角色所在区服唯一标示符 必须 |
| | | * @param zoneName 角色所在区服名 必须 |
| | | * @param block 提交结果block (0:提交失败 1:成功 2:信息不全) |
| | | */ |
| | | + (void)SetUserInfoWithRoleId:(NSString*)roleId roleName:(NSString*)roleName roleLevel:(NSString*)Level zoneId:(NSString*)zoneId zoneName:(NSString*)zoneName attach:(NSString *)attach block:(void(^)(NSInteger code))block; |
| | | |
| | | /** |
| | | 校验票据 |
| | | */ |
| | | +(void)checkAppleReceipt; |
| | | |
| | | /** |
| | | 加载游戏列表 |
| | | |
| | | @param direct 页面显示方式: 竖屏游戏传“1” 横屏游戏传“2” |
| | | @param successBlock 登录成功回调 |
| | | @param failedBlock 失败回调 |
| | | */ |
| | | +(void)loadGameListsWebViewDirect:(NSString *)direct Success:(void(^)(NSString *loginTime ,NSString *userName ,NSString *sign))successBlock failed:(void(^)(NSInteger code, NSString *message)) failedBlock; |
| | | |
| | | @end |
| | | |
| | | NS_ASSUME_NONNULL_END |
New file |
| | |
| | | framework module AoyouSDK { |
| | | umbrella header "AoyouSDK.h" |
| | | |
| | | export * |
| | | module * { export * } |
| | | } |
New file |
| | |
| | | /// |
| | | /// \file QQApiInterface.h |
| | | /// \brief QQApi接口简化封装 |
| | | /// |
| | | /// Created by Tencent on 12-5-15. |
| | | /// Copyright (c) 2012年 Tencent. All rights reserved. |
| | | /// |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import "QQApiInterfaceObject.h" |
| | | |
| | | /** |
| | | \brief 处理来至QQ的请求及响应的回调协议 |
| | | */ |
| | | @protocol QQApiInterfaceDelegate <NSObject> |
| | | |
| | | /** |
| | | 处理来至QQ的请求 |
| | | */ |
| | | - (void)onReq:(QQBaseReq *)req; |
| | | |
| | | /** |
| | | 处理来至QQ的响应 |
| | | */ |
| | | - (void)onResp:(QQBaseResp *)resp; |
| | | |
| | | /** |
| | | 处理QQ在线状态的回调 |
| | | */ |
| | | - (void)isOnlineResponse:(NSDictionary *)response; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | \brief 对QQApi的简单封装类 |
| | | */ |
| | | @interface QQApiInterface : NSObject |
| | | |
| | | /** |
| | | 处理由手Q唤起的跳转请求 |
| | | \param url 待处理的url跳转请求 |
| | | \param delegate 第三方应用用于处理来至QQ请求及响应的委托对象 |
| | | \return 跳转请求处理结果,YES表示成功处理,NO表示不支持的请求协议或处理失败 |
| | | */ |
| | | + (BOOL)handleOpenURL:(NSURL *)url delegate:(id<QQApiInterfaceDelegate>)delegate; |
| | | |
| | | /** |
| | | 向手Q发起分享请求 |
| | | \param req 分享内容的请求 |
| | | \return 请求发送结果码 |
| | | */ |
| | | + (QQApiSendResultCode)sendReq:(QQBaseReq *)req; |
| | | |
| | | /** |
| | | 向手Q QZone结合版发起分享请求 |
| | | \note H5分享只支持单张网络图片的传递 |
| | | \param req 分享内容的请求 |
| | | \return 请求发送结果码 |
| | | */ |
| | | + (QQApiSendResultCode)SendReqToQZone:(QQBaseReq *)req; |
| | | |
| | | /** |
| | | 向手Q 群部落发起分享请求 |
| | | \note H5分享只支持单张网络图片的传递 |
| | | \param req 分享内容的请求 |
| | | \return 请求发送结果码 |
| | | */ |
| | | + (QQApiSendResultCode)SendReqToQQGroupTribe:(QQBaseReq *)req; |
| | | |
| | | /** |
| | | 向手Q发送应答消息 |
| | | \param resp 应答消息 |
| | | \return 应答发送结果码 |
| | | */ |
| | | + (QQApiSendResultCode)sendResp:(QQBaseResp *)resp; |
| | | |
| | | /** |
| | | 检测是否已安装QQ |
| | | \return 如果QQ已安装则返回YES,否则返回NO |
| | | */ |
| | | + (BOOL)isQQInstalled; |
| | | |
| | | /** |
| | | 批量检测QQ号码是否在线 |
| | | */ |
| | | + (void)getQQUinOnlineStatues:(NSArray *)QQUins delegate:(id<QQApiInterfaceDelegate>)delegate; |
| | | |
| | | /** |
| | | 检测QQ是否支持API调用 |
| | | \return 如果当前安装QQ版本支持API调用则返回YES,否则返回NO |
| | | */ |
| | | + (BOOL)isQQSupportApi; |
| | | |
| | | /** |
| | | 启动QQ |
| | | \return 成功返回YES,否则返回NO |
| | | */ |
| | | + (BOOL)openQQ; |
| | | |
| | | /** |
| | | 获取QQ下载地址 |
| | | |
| | | 如果App通过<code>QQApiInterface#isQQInstalled</code>和<code>QQApiInterface#isQQSupportApi</code>检测发现QQ没安装或当前版本QQ不支持API调用,可引导用户通过打开此链接下载最新版QQ。 |
| | | \return iPhoneQQ下载地址 |
| | | */ |
| | | + (NSString *)getQQInstallUrl; |
| | | |
| | | @end |
New file |
| | |
| | | /// |
| | | /// \file QQApiInterfaceObject.h |
| | | /// \brief QQApiInterface所依赖的请求及应答消息对象封装帮助类 |
| | | /// |
| | | /// Created by Tencent on 12-5-15. |
| | | /// Copyright (c) 2012年 Tencent. All rights reserved. |
| | | /// |
| | | |
| | | #ifndef QQApiInterface_QQAPIOBJECT_h |
| | | #define QQApiInterface_QQAPIOBJECT_h |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | |
| | | |
| | | typedef enum |
| | | { |
| | | EQQAPISENDSUCESS = 0, |
| | | EQQAPIQQNOTINSTALLED = 1, |
| | | EQQAPIQQNOTSUPPORTAPI = 2, |
| | | EQQAPIMESSAGETYPEINVALID = 3, |
| | | EQQAPIMESSAGECONTENTNULL = 4, |
| | | EQQAPIMESSAGECONTENTINVALID = 5, |
| | | EQQAPIAPPNOTREGISTED = 6, |
| | | EQQAPIAPPSHAREASYNC = 7, |
| | | EQQAPIQQNOTSUPPORTAPI_WITH_ERRORSHOW = 8, |
| | | EQQAPISENDFAILD = -1, |
| | | //qzone分享不支持text类型分享 |
| | | EQQAPIQZONENOTSUPPORTTEXT = 10000, |
| | | //qzone分享不支持image类型分享 |
| | | EQQAPIQZONENOTSUPPORTIMAGE = 10001, |
| | | //当前QQ版本太低,需要更新至新版本才可以支持 |
| | | EQQAPIVERSIONNEEDUPDATE = 10002, |
| | | } QQApiSendResultCode; |
| | | |
| | | #pragma mark - QQApiObject(分享对象类型) |
| | | |
| | | // QQApiObject control flags |
| | | enum |
| | | { |
| | | kQQAPICtrlFlagQZoneShareOnStart = 0x01, |
| | | kQQAPICtrlFlagQZoneShareForbid = 0x02, |
| | | kQQAPICtrlFlagQQShare = 0x04, |
| | | kQQAPICtrlFlagQQShareFavorites = 0x08, //收藏 |
| | | kQQAPICtrlFlagQQShareDataline = 0x10, //数据线 |
| | | }; |
| | | |
| | | // QQApiObject |
| | | /** \brief 所有在QQ及插件间发送的数据对象的根类。 |
| | | */ |
| | | @interface QQApiObject : NSObject |
| | | @property(nonatomic,retain) NSString* title; ///< 标题,最长128个字符 |
| | | @property(nonatomic,retain) NSString* description; ///<简要描述,最长512个字符 |
| | | |
| | | @property (nonatomic, assign) uint64_t cflag; |
| | | |
| | | @end |
| | | |
| | | // QQApiResultObject |
| | | /** \brief 用于请求回应的数据类型。 |
| | | <h3>可能错误码及描述如下:</h3> |
| | | <TABLE> |
| | | <TR><TD>error</TD><TD>errorDescription</TD><TD>注释</TD></TR> |
| | | <TR><TD>0</TD><TD>nil</TD><TD>成功</TD></TR> |
| | | <TR><TD>-1</TD><TD>param error</TD><TD>参数错误</TD></TR> |
| | | <TR><TD>-2</TD><TD>group code is invalid</TD><TD>该群不在自己的群列表里面</TD></TR> |
| | | <TR><TD>-3</TD><TD>upload photo failed</TD><TD>上传图片失败</TD></TR> |
| | | <TR><TD>-4</TD><TD>user give up the current operation</TD><TD>用户放弃当前操作</TD></TR> |
| | | <TR><TD>-5</TD><TD>client internal error</TD><TD>客户端内部处理错误</TD></TR> |
| | | </TABLE> |
| | | */ |
| | | @interface QQApiResultObject : QQApiObject |
| | | @property(nonatomic,retain) NSString* error; ///<错误 |
| | | @property(nonatomic,retain) NSString* errorDescription; ///<错误描述 |
| | | @property(nonatomic,retain) NSString* extendInfo; ///<扩展信息 |
| | | @end |
| | | |
| | | // QQApiTextObject |
| | | /** \brief 文本对象 |
| | | */ |
| | | @interface QQApiTextObject : QQApiObject |
| | | @property(nonatomic,retain)NSString* text; ///<文本内容,必填,最长1536个字符 |
| | | |
| | | -(id)initWithText:(NSString*)text; ///<初始化方法 |
| | | +(id)objectWithText:(NSString*)text;///<工厂方法,获取一个QQApiTextObject对象. |
| | | @end |
| | | |
| | | // QQApiURLObject |
| | | typedef enum QQApiURLTargetType{ |
| | | QQApiURLTargetTypeNotSpecified = 0x00, |
| | | QQApiURLTargetTypeAudio = 0x01, |
| | | QQApiURLTargetTypeVideo = 0x02, |
| | | QQApiURLTargetTypeNews = 0x03 |
| | | }QQApiURLTargetType; |
| | | |
| | | /** @brief URL对象类型。 |
| | | |
| | | 包括URL地址,URL地址所指向的目标类型及预览图像。 |
| | | */ |
| | | @interface QQApiURLObject : QQApiObject |
| | | /** |
| | | URL地址所指向的目标类型. |
| | | @note 参见QQApi.h 中的 QQApiURLTargetType 定义. |
| | | */ |
| | | @property(nonatomic)QQApiURLTargetType targetContentType; |
| | | |
| | | @property(nonatomic,retain)NSURL* url; ///<URL地址,必填,最长512个字符 |
| | | @property(nonatomic,retain)NSData* previewImageData;///<预览图像数据,最大1M字节 |
| | | @property(nonatomic, retain) NSURL *previewImageURL; ///<预览图像URL **预览图像数据与预览图像URL可二选一 |
| | | |
| | | /** |
| | | 初始化方法 |
| | | */ |
| | | -(id)initWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageData:(NSData*)data targetContentType:(QQApiURLTargetType)targetContentType; |
| | | -(id)initWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageURL:(NSURL*)previewURL targetContentType:(QQApiURLTargetType)targetContentType; |
| | | /** |
| | | 工厂方法,获取一个QQApiURLObject对象 |
| | | */ |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageData:(NSData*)data targetContentType:(QQApiURLTargetType)targetContentType; |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageURL:(NSURL*)previewURL targetContentType:(QQApiURLTargetType)targetContentType; |
| | | @end |
| | | |
| | | // QQApiExtendObject |
| | | /** @brief 扩展数据类型 |
| | | */ |
| | | @interface QQApiExtendObject : QQApiObject |
| | | @property(nonatomic,retain) NSData* data;///<具体数据内容,必填,最大5M字节 |
| | | @property(nonatomic,retain) NSData* previewImageData;///<预览图像,最大1M字节 |
| | | @property(nonatomic,retain) NSArray* imageDataArray;///图片数组(多图暂只支持分享到手机QQ收藏功能) |
| | | |
| | | /** |
| | | 初始化方法 |
| | | @param data 数据内容 |
| | | @param previewImageData 用于预览的图片 |
| | | @param title 标题 |
| | | @param description 此对象,分享的描述 |
| | | */ |
| | | - (id)initWithData:(NSData*)data previewImageData:(NSData*)previewImageData title:(NSString*)title description:(NSString*)description; |
| | | |
| | | /** |
| | | 初始化方法 |
| | | @param data 数据内容 |
| | | @param title 标题 |
| | | @param description 此对象,分享的描述 |
| | | @param imageDataArray 发送的多张图片队列 |
| | | */ |
| | | - (id)initWithData:(NSData *)data previewImageData:(NSData*)previewImageData title:(NSString *)title description:(NSString *)description imageDataArray:(NSArray *)imageDataArray; |
| | | |
| | | /** |
| | | helper方法获取一个autorelease的<code>QQApiExtendObject</code>对象 |
| | | @param data 数据内容 |
| | | @param previewImageData 用于预览的图片 |
| | | @param title 标题 |
| | | @param description 此对象,分享的描述 |
| | | @return |
| | | 一个自动释放的<code>QQApiExtendObject</code>实例 |
| | | */ |
| | | + (id)objectWithData:(NSData*)data previewImageData:(NSData*)previewImageData title:(NSString*)title description:(NSString*)description; |
| | | |
| | | /** |
| | | helper方法获取一个autorelease的<code>QQApiExtendObject</code>对象 |
| | | @param data 数据内容 |
| | | @param previewImageData 用于预览的图片 |
| | | @param title 标题 |
| | | @param description 此对象,分享的描述 |
| | | @param imageDataArray 发送的多张图片队列 |
| | | @return |
| | | 一个自动释放的<code>QQApiExtendObject</code>实例 |
| | | */ |
| | | + (id)objectWithData:(NSData*)data previewImageData:(NSData*)previewImageData title:(NSString*)title description:(NSString*)description imageDataArray:(NSArray*)imageDataArray; |
| | | |
| | | @end |
| | | |
| | | // QQApiImageObject |
| | | /** @brief 图片对象 |
| | | 用于分享图片内容的对象,是一个指定为图片类型的<code>QQApiExtendObject</code> |
| | | */ |
| | | @interface QQApiImageObject : QQApiExtendObject |
| | | @end |
| | | |
| | | // QQApiImageArrayForQZoneObject |
| | | /** @brief 图片对象 |
| | | 用于分享图片到空间,走写说说路径,是一个指定为图片类型的,当图片数组为空时,默认走文本写说说<code>QQApiObject</code> |
| | | */ |
| | | @interface QQApiImageArrayForQZoneObject : QQApiObject |
| | | |
| | | @property(nonatomic,retain) NSArray* imageDataArray;///图片数组 |
| | | |
| | | /** |
| | | 初始化方法 |
| | | @param imageDataArray 图片数组 |
| | | @param title 写说说的内容,可以为空 |
| | | */ |
| | | - (id)initWithImageArrayData:(NSArray*)imageDataArray title:(NSString*)title; |
| | | |
| | | /** |
| | | helper方法获取一个autorelease的<code>QQApiExtendObject</code>对象 |
| | | @param title 写说说的内容,可以为空 |
| | | @param imageDataArray 发送的多张图片队列 |
| | | @return |
| | | 一个自动释放的<code>QQApiExtendObject</code>实例 |
| | | */ |
| | | + (id)objectWithimageDataArray:(NSArray*)imageDataArray title:(NSString*)title; |
| | | |
| | | @end |
| | | |
| | | // QQApiVideoForQZoneObject |
| | | /** @brief 视频对象 |
| | | 用于分享视频到空间,走写说说路径<code>QQApiObject</code> |
| | | assetURL可传ALAsset的ALAssetPropertyAssetURL,或者PHAsset的localIdentifier |
| | | */ |
| | | @interface QQApiVideoForQZoneObject : QQApiObject |
| | | |
| | | @property(nonatomic, retain) NSString *assetURL; |
| | | |
| | | - (id)initWithAssetURL:(NSString*)assetURL title:(NSString*)title; |
| | | |
| | | + (id)objectWithAssetURL:(NSString*)assetURL title:(NSString*)title; |
| | | |
| | | @end |
| | | |
| | | // QQApiWebImageObject |
| | | /** @brief 图片对象 |
| | | 用于分享网络图片内容的对象,是一个指定网络图片url的: 该类型只在2.9.0的h5分享中才支持, |
| | | 原有的手q分享是不支持该类型的。 |
| | | */ |
| | | @interface QQApiWebImageObject : QQApiObject |
| | | |
| | | @property(nonatomic, retain) NSURL *previewImageURL; ///<预览图像URL |
| | | |
| | | /** |
| | | 初始化方法 |
| | | @param previewImageURL 用于预览的图片 |
| | | @param title 标题 |
| | | @param description 此对象,分享的描述 |
| | | */ |
| | | - (id)initWithPreviewImageURL:(NSURL*)previewImageURL title:(NSString*)title description:(NSString*)description; |
| | | |
| | | /** |
| | | helper方法获取一个autorelease的<code>QQApiWebImageObject</code>对象 |
| | | @param previewImageURL 用于预览的图片 |
| | | @param title 标题 |
| | | @param description 此对象,分享的描述 |
| | | */ |
| | | + (id)objectWithPreviewImageURL:(NSURL*)previewImageURL title:(NSString*)title description:(NSString*)description; |
| | | |
| | | @end |
| | | |
| | | // QQApiGroupTribeImageObject |
| | | /** @brief 群部落图片对象 |
| | | 用于分享图片内容的对象,是一个指定为图片类型的 可以指定一些其他的附加数据<code>QQApiExtendObject</code> |
| | | */ |
| | | @interface QQApiGroupTribeImageObject : QQApiImageObject |
| | | { |
| | | NSString *_bid; |
| | | NSString *_bname; |
| | | } |
| | | // 群部落id |
| | | @property (nonatomic, retain)NSString* bid; |
| | | |
| | | // 群部落名称 |
| | | @property (nonatomic, retain)NSString* bname; |
| | | |
| | | @end |
| | | |
| | | |
| | | //QQApiFileObject |
| | | /** @brief 本地文件对象(暂只支持分享到手机QQ数据线功能) |
| | | 用于分享文件内容的对象,是一个指定为文件类型的<code>QQApiExtendObject</code> |
| | | */ |
| | | @interface QQApiFileObject : QQApiExtendObject |
| | | { |
| | | NSString* _fileName; |
| | | } |
| | | @property(nonatomic, retain)NSString* fileName; |
| | | @end |
| | | |
| | | // QQApiAudioObject |
| | | /** @brief 音频URL对象 |
| | | 用于分享目标内容为音频的URL的对象 |
| | | */ |
| | | @interface QQApiAudioObject : QQApiURLObject |
| | | |
| | | @property (nonatomic, retain) NSURL *flashURL; ///<音频URL地址,最长512个字符 |
| | | |
| | | /** |
| | | 获取一个autorelease的<code>QQApiAudioObject</code> |
| | | @param url 音频内容的目标URL |
| | | @param title 分享内容的标题 |
| | | @param description 分享内容的描述 |
| | | @param data 分享内容的预览图像 |
| | | @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE |
| | | */ |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageData:(NSData*)data; |
| | | |
| | | /** |
| | | 获取一个autorelease的<code>QQApiAudioObject</code> |
| | | @param url 音频内容的目标URL |
| | | @param title 分享内容的标题 |
| | | @param description 分享内容的描述 |
| | | @param previewURL 分享内容的预览图像URL |
| | | @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE |
| | | */ |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageURL:(NSURL*)previewURL; |
| | | |
| | | @end |
| | | |
| | | // QQApiVideoObject |
| | | /** @brief 视频URL对象 |
| | | 用于分享目标内容为视频的URL的对象 |
| | | |
| | | QQApiVideoObject类型的分享,目前在Android和PC QQ上接收消息时,展现有待完善,待手机QQ版本以后更新支持 |
| | | 目前如果要分享视频,推荐使用 QQApiNewsObject 类型 |
| | | */ |
| | | @interface QQApiVideoObject : QQApiURLObject |
| | | |
| | | @property (nonatomic, retain) NSURL *flashURL; ///<视频URL地址,最长512个字符 |
| | | |
| | | /** |
| | | 获取一个autorelease的<code>QQApiVideoObject</code> |
| | | @param url 视频内容的目标URL |
| | | @param title 分享内容的标题 |
| | | @param description 分享内容的描述 |
| | | @param data 分享内容的预览图像 |
| | | @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE |
| | | */ |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageData:(NSData*)data; |
| | | |
| | | /** |
| | | 获取一个autorelease的<code>QQApiVideoObject</code> |
| | | @param url 视频内容的目标URL |
| | | @param title 分享内容的标题 |
| | | @param description 分享内容的描述 |
| | | @param previewURL 分享内容的预览图像URL |
| | | @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE |
| | | */ |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageURL:(NSURL*)previewURL; |
| | | |
| | | @end |
| | | |
| | | // QQApiNewsObject |
| | | /** @brief 新闻URL对象 |
| | | 用于分享目标内容为新闻的URL的对象 |
| | | */ |
| | | @interface QQApiNewsObject : QQApiURLObject |
| | | /** |
| | | 获取一个autorelease的<code>QQApiNewsObject</code> |
| | | @param url 视频内容的目标URL |
| | | @param title 分享内容的标题 |
| | | @param description 分享内容的描述 |
| | | @param data 分享内容的预览图像 |
| | | @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE |
| | | */ |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageData:(NSData*)data; |
| | | |
| | | /** |
| | | 获取一个autorelease的<code>QQApiNewsObject</code> |
| | | @param url 视频内容的目标URL |
| | | @param title 分享内容的标题 |
| | | @param description 分享内容的描述 |
| | | @param previewURL 分享内容的预览图像URL |
| | | @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE |
| | | */ |
| | | +(id)objectWithURL:(NSURL*)url title:(NSString*)title description:(NSString*)description previewImageURL:(NSURL*)previewURL; |
| | | |
| | | @end |
| | | |
| | | // QQApiPayObject |
| | | /** \brief 支付对象 |
| | | */ |
| | | @interface QQApiPayObject : QQApiObject |
| | | @property(nonatomic,retain)NSString* OrderNo; ///<支付订单号,必填 |
| | | @property(nonatomic,retain)NSString* AppInfo; ///<支付来源信息,必填 |
| | | |
| | | -(id)initWithOrderNo:(NSString*)OrderNo AppInfo:(NSString*)AppInfo; ///<初始化方法 |
| | | +(id)objectWithOrderNo:(NSString*)OrderNo AppInfo:(NSString*)AppInfo;///<工厂方法,获取一个QQApiPayObject对象. |
| | | @end |
| | | |
| | | // QQApiCommonContentObject; |
| | | /** @brief 通用模板类型对象 |
| | | 用于分享一个固定显示模板的图文混排对象 |
| | | @note 图片列表和文本列表不能同时为空 |
| | | */ |
| | | @interface QQApiCommonContentObject : QQApiObject |
| | | /** |
| | | 预定义的界面布局类型 |
| | | */ |
| | | @property(nonatomic,assign) unsigned int layoutType; |
| | | @property(nonatomic,assign) NSData* previewImageData;///<预览图 |
| | | @property(nonatomic,retain) NSArray* textArray;///<文本列表 |
| | | @property(nonatomic,retain) NSArray* pictureDataArray;///<图片列表 |
| | | +(id)objectWithLayoutType:(int)layoutType textArray:(NSArray*)textArray pictureArray:(NSArray*)pictureArray previewImageData:(NSData*)data; |
| | | /** |
| | | 将一个NSDictionary对象转化为QQApiCommomContentObject,如果无法转换,则返回空 |
| | | */ |
| | | +(id)objectWithDictionary:(NSDictionary*)dic; |
| | | -(NSDictionary*)toDictionary; |
| | | @end |
| | | |
| | | //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| | | // Ad item object definition |
| | | //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| | | /** @brief 广告数据对象 |
| | | */ |
| | | @interface QQApiAdItem : NSObject |
| | | @property(nonatomic,retain) NSString* title; ///<名称 |
| | | @property(nonatomic,retain) NSString* description;///<描述 |
| | | @property(nonatomic,retain) NSData* imageData;///<广告图片 |
| | | @property(nonatomic,retain) NSURL* target;///<广告目标链接 |
| | | @end |
| | | |
| | | // QQApiWPAObject |
| | | /** \brief 发起WPA对象 |
| | | */ |
| | | @interface QQApiWPAObject : QQApiObject |
| | | @property(nonatomic,retain)NSString* uin; ///<想要对话的QQ号 |
| | | |
| | | -(id)initWithUin:(NSString*)uin; ///<初始化方法 |
| | | +(id)objectWithUin:(NSString*)uin;///<工厂方法,获取一个QQApiWPAObject对象. |
| | | @end |
| | | |
| | | // QQApiAddFriendObject |
| | | /** \brief 添加好友 |
| | | */ |
| | | @interface QQApiAddFriendObject : QQApiObject |
| | | @property (nonatomic,retain)NSString* openID; |
| | | @property (nonatomic,retain)NSString* subID; |
| | | @property (nonatomic,retain)NSString* remark; |
| | | |
| | | -(id)initWithOpenID:(NSString*)openID; ///<初始化方法 |
| | | +(id)objecWithOpenID:(NSString*)openID; ///<工厂方法,获取一个QQApiAddFriendObject对象. |
| | | |
| | | @end |
| | | |
| | | // QQApiGameConsortiumBindingGroupObject |
| | | /** \brief 游戏公会绑定群 |
| | | */ |
| | | @interface QQApiGameConsortiumBindingGroupObject : QQApiObject |
| | | @property (nonatomic,retain)NSString* signature; |
| | | @property (nonatomic,retain)NSString* unionid; |
| | | @property (nonatomic,retain)NSString* zoneID; |
| | | @property (nonatomic,retain)NSString* appDisplayName; |
| | | |
| | | -(id)initWithGameConsortium:(NSString*)signature unionid:(NSString*)unionid zoneID:(NSString*)zoneID appDisplayName:(NSString*)appDisplayName; ///<初始化方法 |
| | | +(id)objectWithGameConsortium:(NSString*)signature unionid:(NSString*)unionid zoneID:(NSString*)zoneID appDisplayName:(NSString*)appDisplayName; ///<工厂方法,获取一个QQApiAddFriendObject对象. |
| | | |
| | | @end |
| | | |
| | | // QQApiGameConsortiumBindingGroupObject |
| | | /** \brief 加入群 |
| | | */ |
| | | @interface QQApiJoinGroupObject : QQApiObject |
| | | @property (nonatomic,retain)NSString* groupUin; |
| | | @property (nonatomic,retain)NSString* groupKey; |
| | | |
| | | - (id)initWithGroupInfo:(NSString*)groupUin key:(NSString*)groupKey; ///<初始化方法 |
| | | + (id)objectWithGroupInfo:(NSString*)groupUin key:(NSString*)groupKey; ///<同时提供群号和群KEY 工厂方法,获取一个QQApiAddFriendObject对象. |
| | | + (id)objectWithGroupKey:(NSString*)groupKey; ///<只需要群的KEY 工厂方法,获取一个QQApiAddFriendObject对象. |
| | | |
| | | @end |
| | | |
| | | // QQApiGroupChatObject |
| | | /** \brief 发起群会话对象 |
| | | */ |
| | | @interface QQApiGroupChatObject : QQApiObject |
| | | @property(nonatomic,retain)NSString* groupID; ///<想要对话的群号 |
| | | |
| | | -(id)initWithGroup:(NSString*)groupID; ///<初始化方法 |
| | | +(id)objectWithGroup:(NSString*)groupID;///<工厂方法,获取一个QQApiGroupChatObject对象. |
| | | @end |
| | | |
| | | #pragma mark - QQApi请求消息类型 |
| | | |
| | | /** |
| | | QQApi请求消息类型 |
| | | */ |
| | | enum QQApiInterfaceReqType |
| | | { |
| | | EGETMESSAGEFROMQQREQTYPE = 0, ///< 手Q -> 第三方应用,请求第三方应用向手Q发送消息 |
| | | ESENDMESSAGETOQQREQTYPE = 1, ///< 第三方应用 -> 手Q,第三方应用向手Q分享消息 |
| | | ESHOWMESSAGEFROMQQREQTYPE = 2 ///< 手Q -> 第三方应用,请求第三方应用展现消息中的数据 |
| | | }; |
| | | |
| | | /** |
| | | QQApi应答消息类型 |
| | | */ |
| | | enum QQApiInterfaceRespType |
| | | { |
| | | ESHOWMESSAGEFROMQQRESPTYPE = 0, ///< 第三方应用 -> 手Q,第三方应用应答消息展现结果 |
| | | EGETMESSAGEFROMQQRESPTYPE = 1, ///< 第三方应用 -> 手Q,第三方应用回应发往手Q的消息 |
| | | ESENDMESSAGETOQQRESPTYPE = 2 ///< 手Q -> 第三方应用,手Q应答处理分享消息的结果 |
| | | }; |
| | | |
| | | /** |
| | | QQApi请求消息基类 |
| | | */ |
| | | @interface QQBaseReq : NSObject |
| | | |
| | | /** 请求消息类型,参见\ref QQApiInterfaceReqType */ |
| | | @property (nonatomic, assign) int type; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | QQApi应答消息基类 |
| | | */ |
| | | @interface QQBaseResp : NSObject |
| | | |
| | | /** 请求处理结果 */ |
| | | @property (nonatomic, copy) NSString* result; |
| | | |
| | | /** 具体错误描述信息 */ |
| | | @property (nonatomic, copy) NSString* errorDescription; |
| | | |
| | | /** 应答消息类型,参见\ref QQApiInterfaceRespType */ |
| | | @property (nonatomic, assign) int type; |
| | | |
| | | /** 扩展信息 */ |
| | | @property (nonatomic, assign) NSString* extendInfo; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | GetMessageFromQQReq请求帮助类 |
| | | */ |
| | | @interface GetMessageFromQQReq : QQBaseReq |
| | | |
| | | /** |
| | | 创建一个GetMessageFromQQReq请求实例 |
| | | */ |
| | | + (GetMessageFromQQReq *)req; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | GetMessageFromQQResp应答帮助类 |
| | | */ |
| | | @interface GetMessageFromQQResp : QQBaseResp |
| | | |
| | | /** |
| | | 创建一个GetMessageFromQQResp应答实例 |
| | | \param message 具体分享消息实例 |
| | | \return 新创建的GetMessageFromQQResp应答实例 |
| | | */ |
| | | + (GetMessageFromQQResp *)respWithContent:(QQApiObject *)message; |
| | | |
| | | /** 具体分享消息 */ |
| | | @property (nonatomic, retain) QQApiObject *message; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | SendMessageToQQReq请求帮助类 |
| | | */ |
| | | @interface SendMessageToQQReq : QQBaseReq |
| | | |
| | | /** |
| | | 创建一个SendMessageToQQReq请求实例 |
| | | \param message 具体分享消息实例 |
| | | \return 新创建的SendMessageToQQReq请求实例 |
| | | */ |
| | | + (SendMessageToQQReq *)reqWithContent:(QQApiObject *)message; |
| | | |
| | | /** 具体分享消息 */ |
| | | @property (nonatomic, retain) QQApiObject *message; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | SendMessageToQQResp应答帮助类 |
| | | */ |
| | | @interface SendMessageToQQResp : QQBaseResp |
| | | |
| | | /** |
| | | 创建一个SendMessageToQQResp应答实例 |
| | | \param result 请求处理结果 |
| | | \param errDesp 具体错误描述信息 |
| | | \param extendInfo 扩展信息 |
| | | \return 新创建的SendMessageToQQResp应答实例 |
| | | */ |
| | | + (SendMessageToQQResp *)respWithResult:(NSString *)result errorDescription:(NSString *)errDesp extendInfo:(NSString*)extendInfo; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | ShowMessageFromQQReq请求帮助类 |
| | | */ |
| | | @interface ShowMessageFromQQReq : QQBaseReq |
| | | |
| | | /** |
| | | 创建一个ShowMessageFromQQReq请求实例 |
| | | \param message 具体待展现消息实例 |
| | | \return 新创建的ShowMessageFromQQReq请求实例 |
| | | */ |
| | | + (ShowMessageFromQQReq *)reqWithContent:(QQApiObject *)message; |
| | | |
| | | /** 具体待展现消息 */ |
| | | @property (nonatomic, retain) QQApiObject *message; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | ShowMessageFromQQResp应答帮助类 |
| | | */ |
| | | @interface ShowMessageFromQQResp : QQBaseResp |
| | | |
| | | /** |
| | | 创建一个ShowMessageFromQQResp应答实例 |
| | | \param result 展现消息结果 |
| | | \param errDesp 具体错误描述信息 |
| | | \return 新创建的ShowMessageFromQQResp应答实例 |
| | | */ |
| | | + (ShowMessageFromQQResp *)respWithResult:(NSString *)result errorDescription:(NSString *)errDesp; |
| | | |
| | | @end |
| | | |
| | | #endif |
New file |
| | |
| | | // |
| | | // TencentMessage.h |
| | | // TencentOpenApi_IOS |
| | | // |
| | | // Created by qqconnect on 13-5-29. |
| | | // Copyright (c) 2013年 Tencent. All rights reserved. |
| | | // |
| | | |
| | | #ifndef QQ_OPEN_SDK_LITE |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import "TencentMessageObject.h" |
| | | |
| | | typedef enum |
| | | { |
| | | kIphoneQQ, |
| | | kIphoneQZONE, |
| | | kThirdApp, |
| | | } |
| | | TecnentPlatformType; |
| | | |
| | | typedef enum |
| | | { |
| | | kTencentApiSuccess, |
| | | kTencentApiPlatformUninstall, |
| | | kTencentApiPlatformNotSupport, |
| | | kTencentApiParamsError, |
| | | kTencentApiFail, |
| | | } |
| | | TencentApiRetCode; |
| | | |
| | | @class TencentApiReq; |
| | | @class TencentApiResp; |
| | | |
| | | /** |
| | | * \brief TencentApiInterface的回调 |
| | | * |
| | | * TencentApiInterface的回调接口 |
| | | * \note v1.0版本只支持腾讯业务拉起第三方请求内容 |
| | | */ |
| | | @protocol TencentApiInterfaceDelegate <NSObject> |
| | | |
| | | @optional |
| | | /** |
| | | * 请求获得内容 当前版本只支持第三方相应腾讯业务请求 |
| | | */ |
| | | - (BOOL)onTencentReq:(TencentApiReq *)req; |
| | | |
| | | /** |
| | | * 响应请求答复 当前版本只支持腾讯业务相应第三方的请求答复 |
| | | */ |
| | | - (BOOL)onTencentResp:(TencentApiResp *)resp; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | * \brief TencentApiInterface的回调 |
| | | * |
| | | * TencentApiInterface的调用接口 |
| | | * \note v1.0版本只支持第三方答复内容 |
| | | */ |
| | | @interface TencentApiInterface : NSObject |
| | | |
| | | /** |
| | | * 发送答复返回腾讯业务 |
| | | * \param resp 答复内容 |
| | | * \return 返回码 |
| | | */ |
| | | + (TencentApiRetCode)sendRespMessageToTencentApp:(TencentApiResp *)resp; |
| | | |
| | | /** |
| | | * 是否可以处理拉起协议 |
| | | * param url |
| | | * \param delegate 指定的回调 |
| | | * \return 是否是腾讯API认识的消息类型 |
| | | */ |
| | | + (BOOL)canOpenURL:(NSURL *)url delegate:(id<TencentApiInterfaceDelegate>)delegate; |
| | | |
| | | /** |
| | | * 处理应用拉起协议 |
| | | * param url |
| | | * \param delegate 指定的回调 |
| | | * \return 是否是腾讯API认识的消息类型 |
| | | */ |
| | | + (BOOL)handleOpenURL:(NSURL *)url delegate:(id<TencentApiInterfaceDelegate>)delegate; |
| | | |
| | | /** |
| | | * 用户设备是否安装腾讯APP |
| | | * \param platform 指定的腾讯业务 |
| | | * \return YES:安装 NO:未安装 |
| | | */ |
| | | + (BOOL)isTencentAppInstall:(TecnentPlatformType)platform; |
| | | |
| | | /** |
| | | * 用户设备是否支持调用SDK |
| | | * \param platform 指定的腾讯业务 |
| | | * \return YES:支持 NO:不支持 |
| | | */ |
| | | + (BOOL)isTencentAppSupportTencentApi:(TecnentPlatformType)platform; |
| | | |
| | | @end |
| | | |
| | | #endif |
New file |
| | |
| | | // |
| | | // TencentMessageObject.h |
| | | // TencentOpenApi_IOS |
| | | // |
| | | // Created by qqconnect on 13-5-27. |
| | | // Copyright (c) 2013年 Tencent. All rights reserved. |
| | | // |
| | | |
| | | #ifndef QQ_OPEN_SDK_LITE |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import <UIKit/UIKit.h> |
| | | #import "sdkdef.h" |
| | | |
| | | #define kTextLimit (1024 * 1024) |
| | | #define kDataLimit (1024 * 1024 * 10) |
| | | #define kPreviewDataLimit (1024 * 1024) |
| | | |
| | | @class TencentApiReq; |
| | | @class TencentApiResp; |
| | | |
| | | /** |
| | | * 必填的NSArray型参数 |
| | | */ |
| | | typedef NSArray *TCRequiredArray; |
| | | |
| | | /** |
| | | * 必填的NSDictionary型参数 |
| | | */ |
| | | typedef NSDictionary *TCRequiredDictionary; |
| | | |
| | | /** |
| | | * 必填的TencentApiReq型参数 |
| | | */ |
| | | typedef TencentApiReq *TCRequiredReq; |
| | | |
| | | /** |
| | | * 可选的UIImage类型参数 |
| | | */ |
| | | typedef NSData *TCOptionalData; |
| | | |
| | | |
| | | /** |
| | | * 可选的NSArray型参数 |
| | | */ |
| | | typedef NSArray *TCOptionalArray; |
| | | |
| | | /** |
| | | * 可选的TencentApiReq型参数 |
| | | */ |
| | | typedef TencentApiReq *TCOptionalReq; |
| | | |
| | | /** |
| | | * TencentReqMessageType 请求类型枚举参数 |
| | | */ |
| | | typedef enum |
| | | { |
| | | /** TX APP请求内容填充(需要第三方开发者填充完成内容后需要主动调用sendRespMessageToTencentApp)*/ |
| | | ReqFromTencentAppQueryContent, |
| | | /** TX APP请求展现内容 (不用调用答复) */ |
| | | ReqFromTencentAppShowContent, |
| | | /** 第三方 APP 请求内容 */ |
| | | ReqFromThirdAppQueryContent, |
| | | /** 第三方 APP 请求展现内容(类似分享)*/ |
| | | ReqFromThirdAppShowContent, |
| | | } |
| | | TencentReqMessageType; |
| | | |
| | | typedef enum |
| | | { |
| | | RespFromTencentAppQueryContent, |
| | | RespFromTencentAppShowContent, |
| | | RespFromThirdAppQueryContent, |
| | | RespFromThirdAppShowContent, |
| | | } |
| | | TencentRespMessageType; |
| | | |
| | | /** |
| | | * TencentObjVersion 腾讯API消息类型枚举 |
| | | */ |
| | | typedef enum |
| | | { |
| | | /** 文本类型 */ |
| | | TencentTextObj, |
| | | /** 图片类型 */ |
| | | TencentImageObj, |
| | | /** 音频类型 */ |
| | | TencentAudioObj, |
| | | /** 视频类型 */ |
| | | TencentVideoObj, |
| | | /** 图片视频类 */ |
| | | TencentImageAndVideoObj, |
| | | } |
| | | TencentObjVersion; |
| | | |
| | | /** |
| | | * \brief 请求包 |
| | | * |
| | | * TencentApiReq用来向其他业务发送请求包 |
| | | */ |
| | | @interface TencentApiReq : NSObject<NSCoding> |
| | | |
| | | /** |
| | | * 根据序列号生成一个请求包 |
| | | * \param apiSeq 请求序列号 |
| | | * \param type 请求类型 |
| | | * \return tencentApiReq实例 |
| | | */ |
| | | + (TencentApiReq *)reqFromSeq:(NSInteger)apiSeq type:(TencentReqMessageType)type; |
| | | |
| | | /** 请求类型 */ |
| | | @property (readonly, assign, nonatomic)TCRequiredInt nMessageType; |
| | | |
| | | /** 请求平台 */ |
| | | @property (readonly, assign, nonatomic)NSInteger nPlatform; |
| | | |
| | | /** 请求的SDK版本号 */ |
| | | @property (readonly, assign, nonatomic)NSInteger nSdkVersion; |
| | | |
| | | /** 请求序列号 */ |
| | | @property (readonly, assign, nonatomic)TCRequiredInt nSeq; |
| | | |
| | | /** 第三方的APPID */ |
| | | @property (nonatomic, retain)TCRequiredStr sAppID; |
| | | |
| | | /** 请求内容 TencentBaseMessageObj对象数组 */ |
| | | @property (nonatomic, retain)TCOptionalArray arrMessage; |
| | | |
| | | /** 请求的描述 可以用于告诉对方这个请求的特定场景 */ |
| | | @property (nonatomic, retain)TCOptionalStr sDescription; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | * \brief 答复包 |
| | | * |
| | | * TencentApiResp用来向其他业务发送答复包 |
| | | */ |
| | | @interface TencentApiResp : NSObject<NSCoding> |
| | | |
| | | /** |
| | | * 根据序列号生成一个答复包 |
| | | * \param req 答复对应的请求包(如果req不是TencentApiReq或者他的子类,会抛出异常) |
| | | * \return 答复包体 |
| | | */ |
| | | + (TencentApiResp *)respFromReq:(TencentApiReq *)req; |
| | | |
| | | /** 返回码 */ |
| | | @property (nonatomic, assign)TCOptionalInt nRetCode; |
| | | |
| | | /** 返回消息 */ |
| | | @property (nonatomic, retain)TCOptionalStr sRetMsg; |
| | | |
| | | /** 答复对应的请求包 */ |
| | | @property (nonatomic, retain)TCOptionalReq objReq; |
| | | |
| | | @end |
| | | |
| | | /** |
| | | * \brief 消息体 |
| | | * |
| | | * TencentBaseMessageObj 应用之间传递消息体 |
| | | */ |
| | | @interface TencentBaseMessageObj : NSObject<NSCoding> |
| | | |
| | | /** 消息类型 */ |
| | | @property (nonatomic, assign)NSInteger nVersion; |
| | | |
| | | /** 消息描述 */ |
| | | @property (nonatomic, retain)NSString *sName; |
| | | |
| | | /** 消息的扩展信息 主要是可以用来进行一些请求消息体的描述 譬如图片要求的width height 文字的关键字什么的, 也可以不用填写*/ |
| | | @property (nonatomic, retain)NSDictionary *dictExpandInfo; |
| | | |
| | | /** |
| | | * 消息是否有效 |
| | | */ |
| | | - (BOOL)isVaild; |
| | | |
| | | @end |
| | | |
| | | #pragma mark TencentTextMessage |
| | | /** |
| | | * \brief 文本的消息体 |
| | | * |
| | | * TencentTextMessageObjV1 应用之间传递的文本消息体 |
| | | */ |
| | | @interface TencentTextMessageObjV1 : TencentBaseMessageObj |
| | | |
| | | /** |
| | | * 文本 |
| | | * \note 文本长度不能超过4096个字 |
| | | */ |
| | | @property (nonatomic, retain) NSString *sText; |
| | | |
| | | |
| | | /** |
| | | * 初始化文本消息 |
| | | * \param text 文本 |
| | | * \return 初始化返回的文本消息 |
| | | */ |
| | | - (id)initWithText:(NSString *)text; |
| | | |
| | | @end |
| | | |
| | | |
| | | #pragma mark TecentImageMessage |
| | | |
| | | /** |
| | | * TencentApiImageSourceType 图片数据类型(请求方对数据类型可能会有限制) |
| | | */ |
| | | typedef enum |
| | | { |
| | | /** 图片数据是url或二进制数据 */ |
| | | AllImage, |
| | | /** 图片数据是url */ |
| | | UrlImage, |
| | | /** 图片数据是二进制数据 */ |
| | | DataImage, |
| | | }TencentApiImageSourceType; |
| | | |
| | | /** |
| | | * \brief 图片的消息体 |
| | | * |
| | | * TencentImageMessageObjV1 应用之间传递的图片消息体 |
| | | */ |
| | | @interface TencentImageMessageObjV1 : TencentBaseMessageObj |
| | | |
| | | /** |
| | | * 图片数据 |
| | | * \note 图片不能大于10M |
| | | */ |
| | | @property (nonatomic, retain) NSData *dataImage; |
| | | |
| | | /** |
| | | * 缩略图的数据 |
| | | * \note 图片不能大于1M |
| | | */ |
| | | @property (nonatomic, retain) NSData *dataThumbImage; |
| | | |
| | | /** 图片URL */ |
| | | @property (nonatomic, retain) NSString *sUrl; |
| | | |
| | | /** 图片的描述 */ |
| | | @property (nonatomic, retain) NSString *sDescription; |
| | | |
| | | /** 图片的size */ |
| | | @property (nonatomic, assign) CGSize szImage; |
| | | |
| | | /** |
| | | * 图片来源 |
| | | * \note TencentApiImageSourceType对应的类型 |
| | | */ |
| | | @property (readonly, assign) NSInteger nType; |
| | | |
| | | /** |
| | | * 初始化图片消息 |
| | | * \param dataImage 图片类型 |
| | | * \return 初始化返回的图片消息 |
| | | */ |
| | | - (id)initWithImageData:(NSData *)dataImage; |
| | | |
| | | /** |
| | | * 初始化图片消息 |
| | | * \param url 图片url |
| | | * \return 初始化返回的图片消息 |
| | | */ |
| | | - (id)initWithImageUrl:(NSString *)url; |
| | | |
| | | /** |
| | | * 初始化图片消息 |
| | | * \param type 图片类型 |
| | | * \return 初始化返回的图片消息 |
| | | */ |
| | | - (id)initWithType:(TencentApiImageSourceType)type; |
| | | @end |
| | | |
| | | |
| | | #pragma mark TencentAudioMessage |
| | | /** |
| | | * \brief 音频的消息体 |
| | | * |
| | | * TencentAudioMessageObjV1 应用之间传递的音频消息体 |
| | | */ |
| | | @interface TencentAudioMessageObjV1 : TencentBaseMessageObj |
| | | |
| | | /** 音频URL */ |
| | | @property (nonatomic, retain) NSString *sUrl; |
| | | |
| | | /** |
| | | * 音频的预览图 |
| | | * \note图片不能大于1M |
| | | */ |
| | | @property (nonatomic, retain) NSData *dataImagePreview; |
| | | |
| | | /** 音频的预览图URL */ |
| | | @property (nonatomic, retain) NSString *sImagePreviewUrl; |
| | | |
| | | /** 音频的描述 */ |
| | | @property (nonatomic, retain) NSString *sDescription; |
| | | |
| | | /** |
| | | * 初始化图片消息 |
| | | * \param url 音频URL |
| | | * \return 初始化返回的音频消息 |
| | | */ |
| | | - (id)initWithAudioUrl:(NSString *)url; |
| | | |
| | | @end |
| | | |
| | | |
| | | #pragma mark TencentVideoMessage |
| | | |
| | | /** |
| | | * TencentApiVideoSourceType 视频数据类型(请求方对数据类型可能会有限制) |
| | | */ |
| | | |
| | | typedef enum |
| | | { |
| | | /** 视频来源于本地或网络 */ |
| | | AllVideo, |
| | | /** 视频来源于本地 */ |
| | | LocalVideo, |
| | | /** 视频来源于网络 */ |
| | | NetVideo, |
| | | }TencentApiVideoSourceType; |
| | | |
| | | /** |
| | | * \brief 视频的消息体 |
| | | * |
| | | * TencentVideoMessageV1 应用之间传递的视频消息体 |
| | | */ |
| | | @interface TencentVideoMessageV1 : TencentBaseMessageObj |
| | | |
| | | /** |
| | | * 视频URL |
| | | * \note 不能超过1024 |
| | | */ |
| | | @property (nonatomic, retain) NSString *sUrl; |
| | | |
| | | /** |
| | | * 视频来源 主要是用来让发起方指定视频的来源 |
| | | * \note TencentApiVideoSourceType 对应的类型 只读参数 |
| | | */ |
| | | @property (readonly, assign, nonatomic) NSInteger nType; |
| | | |
| | | /** |
| | | * 视频的预览图 |
| | | * \note 图片不能大于1M |
| | | */ |
| | | @property (nonatomic, retain) NSData *dataImagePreview; |
| | | |
| | | /** 视频的预览图URL */ |
| | | @property (nonatomic, retain) NSString *sImagePreviewUrl; |
| | | |
| | | /** 视频的描述 */ |
| | | @property (nonatomic, retain) NSString *sDescription; |
| | | |
| | | /** |
| | | * 初始化视频消息 |
| | | * \param url 视频URL |
| | | * \param type 视频来源类型 |
| | | * \return 初始化返回的视频消息 |
| | | */ |
| | | - (id)initWithVideoUrl:(NSString *)url type:(TencentApiVideoSourceType)type; |
| | | |
| | | |
| | | /** |
| | | * 初始化视频消息 |
| | | * \param type 视频来源类型 |
| | | * \return 初始化返回的视频消息 |
| | | */ |
| | | - (id)initWithType:(TencentApiVideoSourceType)type; |
| | | @end |
| | | |
| | | #pragma mark TencentImageMessageObj |
| | | /** |
| | | * \brief 视频图片消息体 |
| | | * |
| | | * TencentVideoMessageV1 这是一个扩展的类 是一个图片视频类 |
| | | * \note 图片视频可以任选一个内容填充 但是注意只能填一个 当有一种类型被填充后 另外一个种类型就无法填充了 |
| | | */ |
| | | @interface TencentImageAndVideoMessageObjV1 : TencentBaseMessageObj |
| | | |
| | | /** 图片消息 */ |
| | | @property (nonatomic, retain) TencentImageMessageObjV1 *objImageMessage; |
| | | |
| | | /** 视频消息 */ |
| | | @property (nonatomic, retain) TencentVideoMessageV1 *objVideoMessage; |
| | | |
| | | /** |
| | | * 初始化图片消息 |
| | | * \param dataImage 图片数据 |
| | | * \param url 视频url |
| | | * \return 初始化返回的图片视频消息 |
| | | */ |
| | | - (id)initWithMessage:(NSData *)dataImage videoUrl:(NSString *)url; |
| | | |
| | | /** |
| | | * 设置图片 |
| | | * \param dataImage 图片数据 |
| | | */ |
| | | - (void)setDataImage:(NSData *)dataImage; |
| | | |
| | | /** |
| | | * 设置视频 |
| | | * \param videoUrl 视频URL |
| | | */ |
| | | - (void)setVideoUrl:(NSString *)videoUrl; |
| | | @end |
| | | |
| | | #endif |
New file |
| | |
| | | /// |
| | | /// \file TencentOAuth.h |
| | | /// \brief QQ互联开放平台授权登录及相关开放接口实现类 |
| | | /// |
| | | /// Created by Tencent on 12-12-21. |
| | | /// Copyright (c) 2012年 Tencent. All rights reserved. |
| | | /// |
| | | |
| | | #import <UIKit/UIKit.h> |
| | | #import "sdkdef.h" |
| | | #import "TencentOAuthObject.h" |
| | | #import "TencentApiInterface.h" |
| | | |
| | | @protocol TencentSessionDelegate; |
| | | @protocol TencentLoginDelegate; |
| | | @protocol TencentApiInterfaceDelegate; |
| | | @protocol TencentWebViewDelegate; |
| | | |
| | | @class TencentApiReq; |
| | | @class TencentApiResp; |
| | | |
| | | typedef enum |
| | | { |
| | | kTencentNotAuthorizeState, |
| | | kTencentSSOAuthorizeState, |
| | | kTencentWebviewAuthorzieState, |
| | | } TencentAuthorizeState; |
| | | |
| | | typedef enum |
| | | { |
| | | kAuthModeClientSideToken, |
| | | kAuthModeServerSideCode, |
| | | } TencentAuthMode; |
| | | |
| | | #pragma mark - TencentOAuth(授权登录及相关开放接口调用) |
| | | |
| | | /** |
| | | * \brief TencentOpenAPI授权登录及相关开放接口调用 |
| | | * |
| | | * TencentOAuth实现授权登录逻辑以及相关开放接口的请求调用 |
| | | */ |
| | | @interface TencentOAuth : NSObject |
| | | { |
| | | NSMutableDictionary* _apiRequests; |
| | | NSString* _accessToken; |
| | | NSDate* _expirationDate; |
| | | id<TencentSessionDelegate> _sessionDelegate; |
| | | NSString* _localAppId; |
| | | NSString* _openId; |
| | | NSString* _redirectURI; |
| | | NSArray* _permissions; |
| | | } |
| | | |
| | | /** Access Token凭证,用于后续访问各开放接口 */ |
| | | @property(nonatomic, copy) NSString* accessToken; |
| | | |
| | | /** Access Token的失效期 */ |
| | | @property(nonatomic, copy) NSDate* expirationDate; |
| | | |
| | | /** 已实现的开放接口的回调委托对象 */ |
| | | @property(nonatomic, assign) id<TencentSessionDelegate> sessionDelegate; |
| | | |
| | | /** 第三方应用在开发过程中设置的URLSchema,用于浏览器登录后后跳到第三方应用 */ |
| | | @property(nonatomic, copy) NSString* localAppId; |
| | | |
| | | /** 用户授权登录后对该用户的唯一标识 */ |
| | | @property(nonatomic, copy) NSString* openId; |
| | | |
| | | /** 用户登录成功过后的跳转页面地址 */ |
| | | @property(nonatomic, copy) NSString* redirectURI; |
| | | |
| | | /** 第三方应用在互联开放平台申请的appID */ |
| | | @property(nonatomic, retain) NSString* appId; |
| | | |
| | | /** 主要是互娱的游戏设置uin */ |
| | | @property(nonatomic, retain) NSString* uin; |
| | | |
| | | /** 主要是互娱的游戏设置鉴定票据 */ |
| | | @property(nonatomic, retain) NSString* skey; |
| | | |
| | | /** 登陆透传的数据 */ |
| | | @property(nonatomic, copy) NSDictionary* passData; |
| | | |
| | | /** 授权方式(Client Side Token或者Server Side Code) */ |
| | | @property(nonatomic, assign) TencentAuthMode authMode; |
| | | |
| | | /** union id */ |
| | | @property(nonatomic, retain) NSString* unionid; |
| | | |
| | | /** |
| | | * 用来获得当前sdk的版本号 |
| | | * \return 返回sdk版本号 |
| | | **/ |
| | | |
| | | + (NSString*)sdkVersion; |
| | | |
| | | /** |
| | | * 用来获得当前sdk的小版本号 |
| | | * \return 返回sdk小版本号 |
| | | **/ |
| | | |
| | | + (NSString*)sdkSubVersion; |
| | | |
| | | /** |
| | | * 用来获得当前sdk的是否精简版 |
| | | * \return 返回YES表示精简版 |
| | | **/ |
| | | |
| | | + (BOOL)isLiteSDK; |
| | | |
| | | /** |
| | | * 主要是用来帮助判断是否有登陆被发起,但是还没有过返回结果 |
| | | * \return |
| | | * kTencentNotAuthorizeState:无授权 |
| | | * kTencentSSOAuthorizeState:有人发起了sso授权但无返回 |
| | | * kTencentWebviewAuthorzieState:有人发起了webview授权还未返回 |
| | | **/ |
| | | |
| | | + (TencentAuthorizeState *)authorizeState; |
| | | |
| | | /** |
| | | * 用来获得当前手机qq的版本号 |
| | | * \return 返回手机qq版本号 |
| | | **/ |
| | | + (QQVersion)iphoneQQVersion; |
| | | |
| | | /** |
| | | * 初始化TencentOAuth对象 |
| | | * \param appId 第三方应用在互联开放平台申请的唯一标识 |
| | | * \param delegate 第三方应用用于接收请求返回结果的委托对象 |
| | | * \return 初始化后的授权登录对象 |
| | | */ |
| | | - (id)initWithAppId:(NSString *)appId |
| | | andDelegate:(id<TencentSessionDelegate>)delegate; |
| | | |
| | | |
| | | /** |
| | | * 判断用户手机上是否安装手机QQ |
| | | * \return YES:安装 NO:没安装 |
| | | */ |
| | | + (BOOL)iphoneQQInstalled; |
| | | |
| | | /** |
| | | * 判断用户手机上的手机QQ是否支持SSO登录 |
| | | * \return YES:支持 NO:不支持 |
| | | */ |
| | | + (BOOL)iphoneQQSupportSSOLogin; |
| | | |
| | | /** |
| | | * 判断用户手机上是否安装手机QZone |
| | | * \return YES:安装 NO:没安装 |
| | | */ |
| | | + (BOOL)iphoneQZoneInstalled; |
| | | |
| | | /** |
| | | * 判断用户手机上的手机QZone是否支持SSO登录 |
| | | * \return YES:支持 NO:不支持 |
| | | */ |
| | | + (BOOL)iphoneQZoneSupportSSOLogin; |
| | | |
| | | /** |
| | | * 登录授权 |
| | | * |
| | | * \param permissions 授权信息列 |
| | | */ |
| | | - (BOOL)authorize:(NSArray *)permissions; |
| | | |
| | | /** |
| | | * 登录授权 |
| | | * \param permissions 授权信息列表 |
| | | * \param bInSafari 是否使用safari进行登录.<b>IOS SDK 1.3版本开始此参数废除</b> |
| | | */ |
| | | - (BOOL)authorize:(NSArray *)permissions |
| | | inSafari:(BOOL)bInSafari; |
| | | |
| | | /** |
| | | * 登录授权 |
| | | * \param permissions 授权信息列表 |
| | | * \param localAppId 应用APPID |
| | | * \param bInSafari 是否使用safari进行登录.<b>IOS SDK 1.3版本开始此参数废除</b> |
| | | */ |
| | | - (BOOL)authorize:(NSArray *)permissions |
| | | localAppId:(NSString *)localAppId |
| | | inSafari:(BOOL)bInSafari; |
| | | |
| | | /** |
| | | * 增量授权,因用户没有授予相应接口调用的权限,需要用户确认是否授权 |
| | | * \param permissions 需增量授权的信息列表 |
| | | * \return 增量授权调用是否成功 |
| | | */ |
| | | - (BOOL)incrAuthWithPermissions:(NSArray *)permissions; |
| | | |
| | | /** |
| | | * 重新授权,因token废除或失效导致接口调用失败,需用户重新授权 |
| | | * \param permissions 授权信息列表,同登录授权 |
| | | * \return 授权调用是否成功 |
| | | */ |
| | | - (BOOL)reauthorizeWithPermissions:(NSArray *)permissions; |
| | | |
| | | /** |
| | | * 获取UnindID,可以根据UnindID的比较来确定OpenID是否属于同一个用户 |
| | | * \return NO未登录,信息不足;YES条件满足,发送请求成功,请等待回调 |
| | | */ |
| | | - (BOOL)RequestUnionId; |
| | | |
| | | /** |
| | | * (静态方法)处理应用拉起协议 |
| | | * \param url 处理被其他应用呼起时的逻辑 |
| | | * \return 处理结果,YES表示成功,NO表示失败 |
| | | */ |
| | | + (BOOL)HandleOpenURL:(NSURL *)url; |
| | | |
| | | /** |
| | | * (静态方法)sdk是否可以处理应用拉起协议 |
| | | * \param url 处理被其他应用呼起时的逻辑 |
| | | * \return 处理结果,YES表示可以 NO表示不行 |
| | | */ |
| | | + (BOOL)CanHandleOpenURL:(NSURL *)url; |
| | | |
| | | /** |
| | | * (静态方法)获取TencentOAuth调用的上一次错误信息 |
| | | */ |
| | | + (NSString *)getLastErrorMsg; |
| | | |
| | | /** |
| | | * 以Server Side Code模式授权登录时,通过此接口获取返回的code值; |
| | | * 以Client Side Token模式授权登录时,忽略此接口。 |
| | | */ |
| | | - (NSString *)getServerSideCode; |
| | | |
| | | /** |
| | | * 退出登录(退出登录后,TecentOAuth失效,需要重新初始化) |
| | | * \param delegate 第三方应用用于接收请求返回结果的委托对象 |
| | | */ |
| | | - (void)logout:(id<TencentSessionDelegate>)delegate; |
| | | |
| | | /** |
| | | * 判断登录态是否有效 |
| | | * \return 处理结果,YES表示有效,NO表示无效,请用户重新登录授权 |
| | | */ |
| | | - (BOOL)isSessionValid; |
| | | |
| | | /** |
| | | * 获取用户个人信息 |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)getUserInfo; |
| | | |
| | | /** |
| | | * SDK内置webview实现定向分享时,第三方应用可以根据应用是否在白名单里来开启该配置开关,默认为关闭; |
| | | * 在白名单里的应用调用该接口后,即打开sdk内置webview的二级白名单开关(相对与sdk后台的白名单), |
| | | * 那么在sdk后台白名单校验请求失败的情况下,会继续先尝试采用内置webview进行分享。 |
| | | */ |
| | | - (void)openSDKWebViewQQShareEnable; |
| | | |
| | | |
| | | /** |
| | | * 获取用户QZone相册列表 |
| | | * \attention 需\ref apply_perm |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)getListAlbum; |
| | | |
| | | /** |
| | | * 获取用户QZone相片列表 |
| | | * \attention 需\ref apply_perm |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCListPhotoDic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)getListPhotoWithParams:(NSMutableDictionary *)params; |
| | | |
| | | |
| | | /** |
| | | * 分享到QZone |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCAddShareDic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)addShareWithParams:(NSMutableDictionary *)params; |
| | | |
| | | |
| | | /** |
| | | * 上传照片到QZone指定相册 |
| | | * \attention 需\ref apply_perm |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCUploadPicDic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)uploadPicWithParams:(NSMutableDictionary *)params; |
| | | |
| | | /** |
| | | * 在QZone相册中创建一个新的相册 |
| | | * \attention 需\ref apply_perm |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCAddAlbumDic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)addAlbumWithParams:(NSMutableDictionary *)params; |
| | | |
| | | /** |
| | | * 检查是否是QZone某个用户的粉丝 |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCCheckPageFansDic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)checkPageFansWithParams:(NSMutableDictionary *)params; |
| | | |
| | | /** |
| | | * 在QZone中发表一篇日志 |
| | | * \attention 需\ref apply_perm |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCAddOneBlogDic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)addOneBlogWithParams:(NSMutableDictionary *)params; |
| | | |
| | | /** |
| | | * 在QZone中发表一条说说 |
| | | * \attention 需\ref apply_perm |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCAddTopicDic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)addTopicWithParams:(NSMutableDictionary *)params; |
| | | |
| | | /** |
| | | * 设置QQ头像 使用默认的效果处理设置头像的界面 |
| | | * \attention 需\ref apply_perm |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCSetUserHeadpic |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)setUserHeadpic:(NSMutableDictionary *)params; |
| | | |
| | | |
| | | /** |
| | | * 设置QQ头像 会返回设置头像由第三方自己处理界面的弹出方式 |
| | | * \attention 需\ref apply_perm |
| | | * \param params 参数字典,字典的关键字参见TencentOAuthObject.h中的\ref TCSetUserHeadpic |
| | | * \param viewController 设置头像的界面 |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)setUserHeadpic:(NSMutableDictionary *)params andViewController:(UIViewController **)viewController; |
| | | |
| | | /** |
| | | * 获取QQ会员信息(仅包括是否为QQ会员,是否为年费QQ会员) |
| | | * \attention 需\ref apply_perm |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)getVipInfo; |
| | | |
| | | /** |
| | | * 获取QQ会员详细信息 |
| | | * \attention 需\ref apply_perm |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)getVipRichInfo; |
| | | |
| | | /** |
| | | * QZone定向分享,可以@到具体好友,完成后将触发responseDidReceived:forMessage:回调,message:“SendStory” |
| | | * \param params 参数字典 |
| | | * \param fopenIdArray 第三方应用预传人好友列表,好友以openid标识 |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)sendStory:(NSMutableDictionary *)params friendList:(NSArray *)fopenIdArray; |
| | | |
| | | /** |
| | | * 发送应用邀请,完成后将触发responseDidReceived:forMessage:回调,message:“AppInvitation” |
| | | * \param desc 应用的描述文字,不超过35字符,如果为nil或@“”则显示默认描述 |
| | | * \param imageUrl 应用的图标,如果为nil或者@“”则显示默认图标 |
| | | * \param source 透传参数,由开发者自定义该参数内容 |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)sendAppInvitationWithDescription:(NSString *)desc imageURL:(NSString *)imageUrl source:(NSString *)source; |
| | | |
| | | /** |
| | | * 发起PK或者发送炫耀,完成后将触发responseDidReceived:forMessage:回调,message:“AppChallenge” |
| | | * \param receiver 必须指定一位进行PK或者炫耀的好友,填写其OpenID,填写多个OpenID将截取第一个 |
| | | * \param type 类型,"pk"或者“brag” |
| | | * \param imageUrl 炫耀/挑战场景图的URL |
| | | * \param message 炫耀/挑战中的内容描述,不超过50个字符,超过限制则自动截断 |
| | | * \param source 透传参数,由开发者自定义该参数内容 |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)sendChallenge:(NSString *)receiver type:(NSString *)type imageURL:(NSString *)imageUrl message:(NSString *)message source:(NSString *)source; |
| | | |
| | | /** |
| | | * 赠送或者请求礼物,完成后将触发responseDidReceived:forMessage:回调,message:“AppGiftRequest” |
| | | * \param receiver 赠送或者请求礼物的好友的OpenID,支持填写多个,OpenID之用","分隔,为nil时将由用户通过好友选择器选择好友 |
| | | * \param exclude 用户通过好友选择器选择好友场景下,希望排除的好友(不显示在好友选择器) |
| | | * \param specified 用户通过好友选择器选择好友场景下,希望出现的指定好友 |
| | | * \param only 是否只显示specified指定的好友 |
| | | * \param type 类型,"request"或者“freegift” |
| | | * \param title 免费礼物或请求名称,不超过6个字符 |
| | | * \param message 礼物或请求的默认赠言,控制在35个汉字以内,超过限制自动截断 |
| | | * \param imageUrl 请求或礼物配图的URL,如果不传,则默认在弹框中显示应用的icon |
| | | * \param source 透传参数,由开发者自定义该参数内容 |
| | | * \return 处理结果,YES表示API调用成功,NO表示API调用失败,登录态失败,重新登录 |
| | | */ |
| | | - (BOOL)sendGiftRequest:(NSString *)receiver exclude:(NSString *)exclude specified:(NSString *)specified only:(BOOL)only type:(NSString *)type title:(NSString *)title message:(NSString *)message imageURL:(NSString *)imageUrl source:(NSString *)source; |
| | | |
| | | |
| | | /** |
| | | * 退出指定API调用 |
| | | * \param userData 用户调用某条API的时候传入的保留参数 |
| | | * \return 处理结果,YES表示成功 NO表示失败 |
| | | */ |
| | | - (BOOL)cancel:(id)userData; |
| | | |
| | | /** |
| | | * CGI类任务创建接口 |
| | | * \param apiURL CGI请求的URL地址 |
| | | * \param method CGI请求方式:"GET","POST" |
| | | * \param params CGI请求参数字典 |
| | | * \param callback CGI请求结果的回调接口对象 |
| | | * \return CGI请求任务实例,用于取消任务,返回nil代表任务创建失败 |
| | | */ |
| | | - (TCAPIRequest *)cgiRequestWithURL:(NSURL *)apiURL method:(NSString *)method params:(NSDictionary *)params callback:(id<TCAPIRequestDelegate>)callback; |
| | | |
| | | /** |
| | | * TencentOpenApi发送任务统一接口 |
| | | * \param request 请求发送的任务 |
| | | * \param callback 任务发送后的回调地址 |
| | | */ |
| | | - (BOOL)sendAPIRequest:(TCAPIRequest *)request callback:(id<TCAPIRequestDelegate>)callback; |
| | | |
| | | - (NSString *)getUserOpenID; |
| | | |
| | | @end |
| | | |
| | | #pragma mark - TencentLoginDelegate(授权登录回调协议) |
| | | |
| | | /** |
| | | * \brief TencentLoginDelegate iOS Open SDK 1.3 API回调协议 |
| | | * |
| | | * 第三方应用实现登录的回调协议 |
| | | */ |
| | | @protocol TencentLoginDelegate <NSObject> |
| | | |
| | | @required |
| | | |
| | | /** |
| | | * 登录成功后的回调 |
| | | */ |
| | | - (void)tencentDidLogin; |
| | | |
| | | /** |
| | | * 登录失败后的回调 |
| | | * \param cancelled 代表用户是否主动退出登录 |
| | | */ |
| | | - (void)tencentDidNotLogin:(BOOL)cancelled; |
| | | |
| | | /** |
| | | * 登录时网络有问题的回调 |
| | | */ |
| | | - (void)tencentDidNotNetWork; |
| | | |
| | | @optional |
| | | /** |
| | | * 登录时权限信息的获得 |
| | | */ |
| | | - (NSArray *)getAuthorizedPermissions:(NSArray *)permissions withExtraParams:(NSDictionary *)extraParams; |
| | | |
| | | /** |
| | | * unionID获得 |
| | | */ |
| | | - (void)didGetUnionID; |
| | | |
| | | @end |
| | | |
| | | #pragma mark - TencentSessionDelegate(开放接口回调协议) |
| | | |
| | | /** |
| | | * \brief TencentSessionDelegate iOS Open SDK 1.3 API回调协议 |
| | | * |
| | | * 第三方应用需要实现每条需要调用的API的回调协议 |
| | | */ |
| | | @protocol TencentSessionDelegate<NSObject, TencentLoginDelegate, |
| | | TencentApiInterfaceDelegate, |
| | | TencentWebViewDelegate> |
| | | |
| | | @optional |
| | | |
| | | /** |
| | | * 退出登录的回调 |
| | | */ |
| | | - (void)tencentDidLogout; |
| | | |
| | | /** |
| | | * 因用户未授予相应权限而需要执行增量授权。在用户调用某个api接口时,如果服务器返回操作未被授权,则触发该回调协议接口,由第三方决定是否跳转到增量授权页面,让用户重新授权。 |
| | | * \param tencentOAuth 登录授权对象。 |
| | | * \param permissions 需增量授权的权限列表。 |
| | | * \return 是否仍然回调返回原始的api请求结果。 |
| | | * \note 不实现该协议接口则默认为不开启增量授权流程。若需要增量授权请调用\ref TencentOAuth#incrAuthWithPermissions: \n注意:增量授权时用户可能会修改登录的帐号 |
| | | */ |
| | | - (BOOL)tencentNeedPerformIncrAuth:(TencentOAuth *)tencentOAuth withPermissions:(NSArray *)permissions; |
| | | |
| | | /** |
| | | * [该逻辑未实现]因token失效而需要执行重新登录授权。在用户调用某个api接口时,如果服务器返回token失效,则触发该回调协议接口,由第三方决定是否跳转到登录授权页面,让用户重新授权。 |
| | | * \param tencentOAuth 登录授权对象。 |
| | | * \return 是否仍然回调返回原始的api请求结果。 |
| | | * \note 不实现该协议接口则默认为不开启重新登录授权流程。若需要重新登录授权请调用\ref TencentOAuth#reauthorizeWithPermissions: \n注意:重新登录授权时用户可能会修改登录的帐号 |
| | | */ |
| | | - (BOOL)tencentNeedPerformReAuth:(TencentOAuth *)tencentOAuth; |
| | | |
| | | /** |
| | | * 用户通过增量授权流程重新授权登录,token及有效期限等信息已被更新。 |
| | | * \param tencentOAuth token及有效期限等信息更新后的授权实例对象 |
| | | * \note 第三方应用需更新已保存的token及有效期限等信息。 |
| | | */ |
| | | - (void)tencentDidUpdate:(TencentOAuth *)tencentOAuth; |
| | | |
| | | /** |
| | | * 用户增量授权过程中因取消或网络问题导致授权失败 |
| | | * \param reason 授权失败原因,具体失败原因参见sdkdef.h文件中\ref UpdateFailType |
| | | */ |
| | | - (void)tencentFailedUpdate:(UpdateFailType)reason; |
| | | |
| | | /** |
| | | * 获取用户个人信息回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/getUserInfoResponse.exp success |
| | | * 错误返回示例: \snippet example/getUserInfoResponse.exp fail |
| | | */ |
| | | - (void)getUserInfoResponse:(APIResponse*) response; |
| | | |
| | | |
| | | /** |
| | | * 获取用户QZone相册列表回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/getListAlbumResponse.exp success |
| | | * 错误返回示例: \snippet example/getListAlbumResponse.exp fail |
| | | */ |
| | | - (void)getListAlbumResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 获取用户QZone相片列表 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/getListPhotoResponse.exp success |
| | | * 错误返回示例: \snippet example/getListPhotoResponse.exp fail |
| | | */ |
| | | - (void)getListPhotoResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 检查是否是QZone某个用户的粉丝回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/checkPageFansResponse.exp success |
| | | * 错误返回示例: \snippet example/checkPageFansResponse.exp fail |
| | | */ |
| | | - (void)checkPageFansResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 分享到QZone回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/addShareResponse.exp success |
| | | * 错误返回示例: \snippet example/addShareResponse.exp fail |
| | | */ |
| | | - (void)addShareResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 在QZone相册中创建一个新的相册回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/addAlbumResponse.exp success |
| | | * 错误返回示例: \snippet example/addAlbumResponse.exp fail |
| | | */ |
| | | - (void)addAlbumResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 上传照片到QZone指定相册回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/uploadPicResponse.exp success |
| | | * 错误返回示例: \snippet example/uploadPicResponse.exp fail |
| | | */ |
| | | - (void)uploadPicResponse:(APIResponse*) response; |
| | | |
| | | |
| | | /** |
| | | * 在QZone中发表一篇日志回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/addOneBlogResponse.exp success |
| | | * 错误返回示例: \snippet example/addOneBlogResponse.exp fail |
| | | */ |
| | | - (void)addOneBlogResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 在QZone中发表一条说说回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/addTopicResponse.exp success |
| | | * 错误返回示例: \snippet example/addTopicResponse.exp fail |
| | | */ |
| | | - (void)addTopicResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 设置QQ头像回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/setUserHeadpicResponse.exp success |
| | | * 错误返回示例: \snippet example/setUserHeadpicResponse.exp fail |
| | | */ |
| | | - (void)setUserHeadpicResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 获取QQ会员信息回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \remarks 正确返回示例: \snippet example/getVipInfoResponse.exp success |
| | | * 错误返回示例: \snippet example/getVipInfoResponse.exp fail |
| | | */ |
| | | - (void)getVipInfoResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * 获取QQ会员详细信息回调 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | */ |
| | | - (void)getVipRichInfoResponse:(APIResponse*) response; |
| | | |
| | | /** |
| | | * sendStory分享的回调(已废弃,使用responseDidReceived:forMessage:) |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | */ |
| | | - (void)sendStoryResponse:(APIResponse*) response; |
| | | |
| | | |
| | | /** |
| | | * 社交API统一回调接口 |
| | | * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse |
| | | * \param message 响应的消息,目前支持‘SendStory’,‘AppInvitation’,‘AppChallenge’,‘AppGiftRequest’ |
| | | */ |
| | | - (void)responseDidReceived:(APIResponse*)response forMessage:(NSString *)message; |
| | | |
| | | /** |
| | | * post请求的上传进度 |
| | | * \param tencentOAuth 返回回调的tencentOAuth对象 |
| | | * \param bytesWritten 本次回调上传的数据字节数 |
| | | * \param totalBytesWritten 总共已经上传的字节数 |
| | | * \param totalBytesExpectedToWrite 总共需要上传的字节数 |
| | | * \param userData 用户自定义数据 |
| | | */ |
| | | - (void)tencentOAuth:(TencentOAuth *)tencentOAuth didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite userData:(id)userData; |
| | | |
| | | |
| | | /** |
| | | * 通知第三方界面需要被关闭 |
| | | * \param tencentOAuth 返回回调的tencentOAuth对象 |
| | | * \param viewController 需要关闭的viewController |
| | | */ |
| | | - (void)tencentOAuth:(TencentOAuth *)tencentOAuth doCloseViewController:(UIViewController *)viewController; |
| | | |
| | | @end |
| | | |
| | | #pragma mark - TencentWebViewDelegate(H5登录webview旋转方向回调) |
| | | |
| | | /** |
| | | * \brief TencentWebViewDelegate: H5登录webview旋转方向回调协议 |
| | | * |
| | | * 第三方应用可以根据自己APP的旋转方向限制,通过此协议设置 |
| | | */ |
| | | @protocol TencentWebViewDelegate <NSObject> |
| | | @optional |
| | | - (BOOL) tencentWebViewShouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; |
| | | - (NSUInteger) tencentWebViewSupportedInterfaceOrientationsWithWebkit; |
| | | - (BOOL) tencentWebViewShouldAutorotateWithWebkit; |
| | | @end |
New file |
| | |
| | | /// |
| | | /// \file TencentOAuthObject.h |
| | | /// 对开放接口的调用提供参数字典封装的辅助类 |
| | | /// |
| | | /// Created by Tencent on 12-12-28. |
| | | /// Copyright (c) 2012年 Tencent. All rights reserved. |
| | | /// |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import <UIKit/UIKit.h> |
| | | #import "sdkdef.h" |
| | | |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCAddTopicDic |
| | | |
| | | /** |
| | | * \brief 发表说说的参数字典定义 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCAddTopicDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCAddTopicDic *) dictionary; |
| | | |
| | | /** |
| | | * 发布心情时引用的信息的类型。 |
| | | * \note 1表示图片; 2表示网页; 3表示视频 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramRichtype; |
| | | |
| | | /** |
| | | * 发布心情时引用的信息的值。有richtype时必须有richval |
| | | * |
| | | * \note |
| | | * -# 当richtype为图片(即richtype为1,应用场景为发布心情时引用某张图片)时,\n |
| | | * richval需要传入该图片的相关参数。引用的图片来源分为两种:一种为网站图片,\n |
| | | * 一种为QQ空间相册中的某张图片。 |
| | | * - 当引用的图片来自网站,richval包含下列参数的值:\n |
| | | * | 参数名称 | 是否必须 | 类型 | 描述 | |
| | | * | ------ | ------- | ------ | ----------------- | |
| | | * | url | 必须 | string | 网站图片的URL | |
| | | * | height | 必须 | string | 图片高度,单位: px | |
| | | * | width | 必须 | string | 图片宽度,单位: px | |
| | | * \n |
| | | * 输入时每个值中间用“&”分隔,如下所示:\n |
| | | * “url=http://qq.com/logo.png&width=25&height=21” |
| | | * |
| | | * - 当引用的图片来自QQ空间相册,richval包含下列参数的值。\n |
| | | * 这些值都需要通过调用相册OpenAPI来获得。参数意义如下:\n |
| | | * | 参数名称 | 是否必须 | 类型 | 描述 | |
| | | * | --------- | ------ | ------ | ---------------------------------- | |
| | | * | albumid | 必须 | string | 图片所属空间相册的ID | |
| | | * | pictureid | 必须 | string | 图片ID | |
| | | * | sloc | 必须 | string | 小图ID | |
| | | * | pictype | | string | 图片类型(JPG = 1;GIF = 2;PNG = 3) | |
| | | * | picheight | | string | 图片高度,单位: px | |
| | | * | picwidth | | string | 图片宽度,单位: px | |
| | | * 输入时每个值中间用逗号分隔,如下所示 :\n |
| | | * “albumid,pictureid,sloc,pictype,picheight,picwidth” |
| | | * -# 当richtype为网页(即richtype为2,应用场景为针对某网页发表评论)时,\n |
| | | * richval需要传入该网页的URL,发表为feeds时,后台会自动将该URL转换为短URL。 |
| | | * -# 当richtype为视频(即richtype为3,应用场景为针对某视频发表评论)时,\n |
| | | * richval需要传入该视频的URL,发表为feeds时,后台会对该URL进行解析,\n |
| | | * 在feeds上显示播放器,视频源及缩略图。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramRichval; |
| | | |
| | | /** |
| | | * 发布的心情的内容。 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramCon; |
| | | |
| | | /** |
| | | * 地址文。例如:广东省深圳市南山区高新科技园腾讯大厦。lbs_nm,lbs_x,lbs_y通常一起使用,来明确标识一个地址。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramLbs_nm; |
| | | |
| | | /** |
| | | * 经度。-180.0到+180.0,+表示东经。lbs_nm,lbs_x,lbs_y通常一起使用,来明确标识一个地址。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramLbs_x; |
| | | |
| | | /** |
| | | * 纬度。-90.0到+90.0,+表示北纬。lbs_nm,lbs_x,lbs_y通常一起使用,来明确标识一个地址。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramLbs_y; |
| | | |
| | | /** |
| | | * 第三方应用的平台类型。 |
| | | * \note 1表示QQ空间; 2表示腾讯朋友; 3表示腾讯微博平台; 4表示腾讯Q+平台。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramThirdSource; |
| | | @end |
| | | |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCAddOneBlogDic |
| | | /** |
| | | * \brief 发表日志的参数字典定义 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCAddOneBlogDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCAddOneBlogDic *) dictionary; |
| | | |
| | | /** |
| | | * 日志标题(纯文本,最大长度128个字节,utf-8编码)。 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramTitle; |
| | | |
| | | /** |
| | | * content 文章内容(html数据,最大长度100*1024个字节,utf-8编码) |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramContent; |
| | | @end |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCAddAlbumDic |
| | | /** |
| | | * \brief 创建空间相册的参数字典定义 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCAddAlbumDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCAddAlbumDic *) dictionary; |
| | | |
| | | /** |
| | | * albumname 必须 string 相册名 不能超过30个字符。 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramAlbumname; |
| | | |
| | | |
| | | /** |
| | | * albumdesc string 相册描述,不能超过200个字符。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramAlbumdesc; |
| | | |
| | | /** |
| | | * priv string 相册权限 |
| | | * |
| | | * \note 其取值含义为: 1=公开;3=只主人可见; 4=QQ好友可见; 5=问答加密。\n |
| | | * 不传则相册默认为公开权限。\n |
| | | * 如果priv取值为5,即相册是问答加密的,则必须包含问题和答案两个参数:\n |
| | | * - question: 问题,不能超过30个字符。 |
| | | * - answer: 答案,不能超过30个字符。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramPriv; |
| | | |
| | | /** |
| | | * question 问题,不能超过30个字符。 |
| | | * \note 如果priv取值为5,必须包含这个参数: |
| | | **/ |
| | | @property (nonatomic, retain) TCOptionalStr paramQuestion; |
| | | |
| | | /** |
| | | * answer 答案,不能超过30个字符。 |
| | | * \note 如果priv取值为5,必须包含这个参数: |
| | | **/ |
| | | @property (nonatomic, retain) TCOptionalStr paramAnswer; |
| | | |
| | | @end |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCUploadPicDic |
| | | /** |
| | | * \brief 上传一张照片到QQ空间相册的参数字典定义 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCUploadPicDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCUploadPicDic *) dictionary; |
| | | |
| | | /** |
| | | * photodesc string 照片描述,注意照片描述不能超过200个字符。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramPhotodesc; |
| | | /** |
| | | * string 照片的命名,必须以.jpg, .gif, .png, .jpeg, .bmp此类后缀结尾。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramTitle; |
| | | |
| | | /** |
| | | * string 相册id。可不填,不填时则根据“mobile”标识选择默认上传的相册。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramAlbumid; |
| | | |
| | | /** |
| | | * 标志位 |
| | | * |
| | | * \note 0表示PC,1表示手机。用于当不传相册id时(即albumid为空时)控制是否传到手机相册。\n |
| | | * -# 如果传1,则当albumid为空时,图片会上传到手机相册; |
| | | * -# 如果不传或传0,则当albumid为空时,图片会上传到贴图相册; |
| | | */ |
| | | @property (nonatomic, assign) TCOptionalStr paramMobile; |
| | | |
| | | /** |
| | | * x string 照片拍摄时的地理位置的经度。请使用原始数据(纯经纬度,0-360)。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramX; |
| | | |
| | | /** |
| | | * y string 照片拍摄时的地理位置的纬度。请使用原始数据(纯经纬度,0-360)。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramY; |
| | | |
| | | /** |
| | | * picture 必须 string 上传照片的文件名以及图片的内容(在发送请求时,图片内容以二进制数据流的形式发送,见下面的请求示例),注意照片名称不能超过30个字符。 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredImage paramPicture; |
| | | |
| | | /** |
| | | * needfeed int 标识上传照片时是否要发feed |
| | | * \note(0:不发feed; 1:发feed)。如果不填则默认为发feed。 |
| | | */ |
| | | @property (nonatomic, assign)TCOptionalStr paramNeedfeed; |
| | | |
| | | /** |
| | | * successnum int 批量上传照片时,已成功上传的张数,指明上传完成情况。 |
| | | * \note 单张上传时可以不填,不填则默认为0。 |
| | | */ |
| | | @property (nonatomic, assign)TCOptionalStr paramSuccessnum; |
| | | |
| | | /** |
| | | * picnum int 批量上传照片的总张数,如果不填则默认为1。 |
| | | * \note |
| | | * - 如果picnum=1,为单张上传,发送单张上传feed; |
| | | * - 如果picnum>1,为批量上传,发送批量上传feed。 |
| | | * 批量上传方式:picnum为一次上传照片的张数,successnum初始值为0,每调用一次照片上传接口后递增其值。 |
| | | * 信息中心中的feed表现形式:批量上传时最新的7张在feed中展示。其中最新上传的一张图片展示为大图,剩下的 |
| | | * 六张按从新到旧的顺序展示为小图,其他图片不在feed中展示。 |
| | | */ |
| | | @property (nonatomic, assign)TCOptionalStr paramPicnum; |
| | | |
| | | @end |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCAddShareDic |
| | | /** |
| | | * \brief 同步分享到QQ空间,腾讯微博的参数字典定义 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCAddShareDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCAddShareDic *) dictionary; |
| | | |
| | | /** |
| | | * title 必须 string feeds的标题 最长36个中文字,超出部分会被截断。 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramTitle; |
| | | |
| | | |
| | | /** |
| | | * url 必须 string 分享所在网页资源的链接,点击后跳转至第三方网页,对应上文接口说明中2的超链接。请以http://开头。 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramUrl; |
| | | |
| | | |
| | | /** |
| | | * comment string 用户评论内容,也叫发表分享时的分享理由 禁止使用系统生产的语句进行代替。 |
| | | * 最长40个中文字,超出部分会被截断。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramComment; |
| | | |
| | | |
| | | /** |
| | | * summary string 所分享的网页资源的摘要内容,或者是网页的概要描述 最长80个中文字,超出部分会被截断。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramSummary; |
| | | |
| | | /** |
| | | * images string 所分享的网页资源的代表性图片链接",请以http://开头,长度限制255字符。多张图片以竖线(|)分隔,目前只有第一张图片有效,图片规格100*100为佳。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramImages; |
| | | |
| | | /** |
| | | * type string 分享内容的类型。 |
| | | * |
| | | * \note 4表示网页;5表示视频(type=5时,必须传入playurl) |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramType; |
| | | |
| | | /** |
| | | * playurl string 长度限制为256字节。仅在type=5的时候有效,表示视频的swf播放地址。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramPlayurl; |
| | | |
| | | /** |
| | | * site 必须 string 分享的来源网站名称,请填写网站申请接入时注册的网站名称 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramSite; |
| | | |
| | | /** |
| | | * fromurl 必须 string 分享的来源网站对应的网站地址url 请以http://开头。 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramFromurl; |
| | | |
| | | /** |
| | | * nswb string 值为1时,表示分享不默认同步到微博,其他值或者不传此参数表示默认同步到微博。 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramNswb; |
| | | |
| | | @end |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCCheckPageFansDic |
| | | /** |
| | | * \brief 验证是否认证空间粉丝tttyttyyyu的参数字典定义 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCCheckPageFansDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCCheckPageFansDic *) dictionary; |
| | | |
| | | /** |
| | | * 表示认证空间的QQ号码 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramPage_id; |
| | | @end |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCSetUserHeadpic |
| | | /** |
| | | * \brief 设置用户头像 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCSetUserHeadpic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCSetUserHeadpic *) dictionary; |
| | | |
| | | /** |
| | | * 设置用户头像的图片 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredImage paramImage; |
| | | |
| | | /** |
| | | * 图片的文件名 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramFileName; |
| | | @end |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCListPhotoDic |
| | | |
| | | /** |
| | | * \brief 获取用户QQ空间相册中的照片列表 |
| | | * |
| | | * 可以直接填写相应参数后将对象当作参数传入API中 |
| | | */ |
| | | @interface TCListPhotoDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCListPhotoDic *) dictionary; |
| | | |
| | | /** |
| | | * 表示要获取的照片列表所在的相册ID |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramAlbumid; |
| | | |
| | | @end |
| | | |
| | | #pragma mark - |
| | | #pragma mark TCSendStoryDic |
| | | /** |
| | | * \brief QQ空间定向分享的参数字典定义 |
| | | * |
| | | * 该分享支持@到指定好友,最多支持10个好友。 |
| | | * 其中第三方应用可预传最多5个指定好友的openid,其余好友由用户自行选择。 |
| | | * 该分享形式仅提供跳QZone分享和本地Html5分享两种形式。 |
| | | * sendStroy不支持userData参数 |
| | | */ |
| | | @interface TCSendStoryDic : TCAPIRequest |
| | | |
| | | /** |
| | | * 返回一个对象用来进行API参数的填充 |
| | | * |
| | | * \note 不用释放,返回的对象是自动释放的 |
| | | */ |
| | | + (TCSendStoryDic *) dictionary; |
| | | |
| | | /** |
| | | * 分享的标题 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramTitle; |
| | | |
| | | /** |
| | | * 故事摘要,最多不超过50个汉字,可以为空 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramSummary; |
| | | |
| | | /** |
| | | * 默认展示在输入框里的分享理由,最多120个汉字,可以为空 |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramDescription; |
| | | |
| | | /** |
| | | * 图片url |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramPics; |
| | | |
| | | /** |
| | | * 如果不填,则默认为"进入应用" |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredStr paramAct; |
| | | |
| | | /** |
| | | * 点击分享的Url |
| | | */ |
| | | @property (nonatomic, retain) TCOptionalStr paramShareUrl; |
| | | |
| | | @end |
New file |
| | |
| | | /// |
| | | /// \file sdkdef.h |
| | | /// \brief SDK中相关常量定义 |
| | | /// |
| | | /// Created by Tencent on 12-12-25. |
| | | /// Copyright (c) 2012年 Tencent. All rights reserved. |
| | | /// |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import <UIKit/UIKit.h> |
| | | |
| | | /** |
| | | * \brief 设置sdk的log等级 |
| | | */ |
| | | typedef enum { |
| | | TCOLogLevel_Disabled = -1, // 关闭所有log |
| | | TCOLogLevel_Error = 0, |
| | | TCOLogLevel_Warning, |
| | | TCOLogLevel_Info, |
| | | TCOLogLevel_Debug, |
| | | } TCOLogLevel; |
| | | |
| | | /** |
| | | * \brief 手机qq的当前版本 |
| | | */ |
| | | typedef enum QQVersion |
| | | { |
| | | kQQUninstall, |
| | | kQQVersion3_0, |
| | | kQQVersion4_0, //支持sso登陆 |
| | | kQQVersion4_2_1, //ios7兼容 |
| | | kQQVersion4_5, //4.5版本,wpa会话 |
| | | kQQVersion4_6, //4.6版本,sso登陆信令通道切换 |
| | | kQQVersion4_7, //4.7版本 不确定新支持了什么样的属性 |
| | | } QQVersion; |
| | | |
| | | /** |
| | | * \brief APIResponse.retCode可能的枚举常量 |
| | | */ |
| | | typedef enum |
| | | { |
| | | URLREQUEST_SUCCEED = 0, /**< 网络请求成功发送至服务器,并且服务器返回数据格式正确 |
| | | * \note 这里包括所请求业务操作失败的情况,例如没有授权等原因导致 |
| | | */ |
| | | |
| | | URLREQUEST_FAILED = 1, /**< 网络异常,或服务器返回的数据格式不正确导致无法解析 */ |
| | | } REPONSE_RESULT; |
| | | |
| | | /** |
| | | * \brief 增量授权失败原因 |
| | | * |
| | | * \note 增量授权失败不影响原token的有效性(原token已失效的情况除外) |
| | | */ |
| | | typedef enum |
| | | { |
| | | kUpdateFailUnknown = 1, ///< 未知原因 |
| | | kUpdateFailUserCancel, ///< 用户取消 |
| | | kUpdateFailNetwork, ///< 网络问题 |
| | | } UpdateFailType; |
| | | |
| | | /** |
| | | * \brief 封装服务器返回的结果 |
| | | * |
| | | * APIResponse用于封装所有请求的返回结果,包括错误码、错误信息、原始返回数据以及返回数据的json格式字典 |
| | | */ |
| | | @interface APIResponse : NSObject<NSCoding> { |
| | | int _detailRetCode; |
| | | int _retCode; |
| | | int _seq; |
| | | NSString *_errorMsg; |
| | | NSDictionary *_jsonResponse; |
| | | NSString *_message; |
| | | id _userData; |
| | | } |
| | | |
| | | /** |
| | | * 新增的详细错误码\n |
| | | * detailRetCode主要用于区分不同的错误情况,参见\ref OpenSDKError |
| | | */ |
| | | @property (nonatomic, assign) int detailRetCode; |
| | | |
| | | /** |
| | | * 网络请求是否成功送达服务器,以及服务器返回的数据格式是否正确\n |
| | | * retCode具体取值可参考\ref REPONSE_RESULT |
| | | */ |
| | | @property (nonatomic, assign) int retCode; |
| | | |
| | | /** |
| | | * 网络请求对应的递增序列号,方便内部管理 |
| | | */ |
| | | @property (nonatomic, assign) int seq; |
| | | |
| | | /** |
| | | * 错误提示语 |
| | | */ |
| | | @property (nonatomic, retain) NSString *errorMsg; |
| | | |
| | | /** |
| | | * 服务器返回数据的json格式字典\n |
| | | * 字典内具体参数的命名和含义请参考\ref api_spec |
| | | */ |
| | | @property (nonatomic, retain) NSDictionary *jsonResponse; |
| | | |
| | | /** |
| | | * 服务器返回的原始数据字符串 |
| | | */ |
| | | @property (nonatomic, retain) NSString *message; |
| | | |
| | | /** |
| | | * 用户保留数据 |
| | | */ |
| | | @property (nonatomic, retain) id userData; |
| | | |
| | | @end |
| | | |
| | | |
| | | /** |
| | | * 用户自定义的保留字段 |
| | | */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_USER_DATA; |
| | | |
| | | /** |
| | | * \name 应用邀请参数字段定义 |
| | | */ |
| | | ///@{ |
| | | |
| | | /** 应用邀请展示图片url的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_APP_ICON; |
| | | |
| | | /** 应用邀请描述文本的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_APP_DESC; |
| | | |
| | | /** 应用邀请好友列表的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_APP_INVITED_OPENIDS; |
| | | |
| | | ///@} |
| | | |
| | | /** |
| | | * \name sendStory新分享参数字段定义 |
| | | */ |
| | | ///@{ |
| | | |
| | | /** 预填入接受人列表的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SENDSTORY_RECEIVER; |
| | | |
| | | /** 分享feeds标题的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SENDSTORY_TITLE; |
| | | |
| | | /** 分享feeds评论内容的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SENDSTORY_COMMENT; |
| | | |
| | | /** 分享feeds摘要的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SENDSTORY_SUMMARY; |
| | | |
| | | /** 分享feeds展示图片url的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SENDSTORY_IMAGE; |
| | | |
| | | /** 分享feeds跳转链接url的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SENDSTORY_URL; |
| | | |
| | | /** 分享feeds点击操作默认行为的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SENDSTORY_ACT; |
| | | |
| | | ///@} |
| | | |
| | | /** |
| | | * \name 设置头像参数字段定义 |
| | | */ |
| | | ///@{ |
| | | |
| | | /** 头像图片数据的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SETUSERHEAD_PIC; |
| | | |
| | | /** 头像图片文件名的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_SETUSERHEAD_FILENAME; |
| | | |
| | | ///@} |
| | | |
| | | /** |
| | | * \name 服务器返回数据的参数字段定义 |
| | | */ |
| | | ///@{ |
| | | |
| | | /** 服务器返回码的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_RETCODE; |
| | | |
| | | /** 服务器返回错误信息的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_MESSAGE; |
| | | |
| | | /** 服务器返回额外数据的key */ |
| | | FOUNDATION_EXTERN NSString * const PARAM_DATA; |
| | | |
| | | ///@} |
| | | |
| | | /** |
| | | * \name 错误信息相关常量定义 |
| | | */ |
| | | ///@{ |
| | | |
| | | /** 详细错误信息字典中额外信息的key */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorKeyExtraInfo; |
| | | |
| | | /** 详细错误信息字典中返回码的key */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorKeyRetCode; |
| | | |
| | | /** 详细错误信息字典中错误语句的key */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorKeyMsg; |
| | | |
| | | /** 不支持的接口 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgUnsupportedAPI; |
| | | |
| | | /** 操作成功 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgSuccess; |
| | | |
| | | /** 未知错误 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgUnknown; |
| | | |
| | | /** 用户取消 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgUserCancel; |
| | | |
| | | /** 请重新登录 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgReLogin; |
| | | |
| | | /** 应用没有操作权限 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgOperationDeny; |
| | | |
| | | /** 网络异常或没有网络 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgNetwork; |
| | | |
| | | /** URL格式或协议错误 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgURL; |
| | | |
| | | /** 解析数据出错 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgDataParse; |
| | | |
| | | /** 传入参数有误 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgParam; |
| | | |
| | | /** 连接超时 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgTimeout; |
| | | |
| | | /** 安全问题 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgSecurity; |
| | | |
| | | /** 文件读写错误 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgIO; |
| | | |
| | | /** 服务器端错误 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgServer; |
| | | |
| | | /** 页面错误 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgWebPage; |
| | | |
| | | /** 设置头像图片过大 */ |
| | | FOUNDATION_EXTERN NSString * const TCOpenSDKErrorMsgUserHeadPicLarge; |
| | | |
| | | ///@} |
| | | |
| | | /** |
| | | * \brief SDK新增详细错误常量 |
| | | */ |
| | | typedef enum |
| | | { |
| | | kOpenSDKInvalid = -1, ///< 无效的错误码 |
| | | kOpenSDKErrorUnsupportedAPI = -2, ///< 不支持的接口 |
| | | |
| | | /** |
| | | * \name CommonErrorCode |
| | | * 公共错误码 |
| | | */ |
| | | ///@{ |
| | | kOpenSDKErrorSuccess = 0, ///< 成功 |
| | | kOpenSDKErrorUnknown, ///< 未知错误 |
| | | kOpenSDKErrorUserCancel, ///< 用户取消 |
| | | kOpenSDKErrorReLogin, ///< token无效或用户未授权相应权限需要重新登录 |
| | | kOpenSDKErrorOperationDeny, ///< 第三方应用没有该api操作的权限 |
| | | ///@} |
| | | |
| | | /** |
| | | * \name NetworkRelatedErrorCode |
| | | * 网络相关错误码 |
| | | */ |
| | | ///@{ |
| | | kOpenSDKErrorNetwork, ///< 网络错误,网络不通或连接不到服务器 |
| | | kOpenSDKErrorURL, ///< URL格式或协议错误 |
| | | kOpenSDKErrorDataParse, ///< 数据解析错误,服务器返回的数据解析出错 |
| | | kOpenSDKErrorParam, ///< 传入参数错误 |
| | | kOpenSDKErrorConnTimeout, ///< http连接超时 |
| | | kOpenSDKErrorSecurity, ///< 安全问题 |
| | | kOpenSDKErrorIO, ///< 下载和文件IO错误 |
| | | kOpenSDKErrorServer, ///< 服务器端错误 |
| | | ///@} |
| | | |
| | | /** |
| | | * \name WebViewRelatedError |
| | | * webview特有错误 |
| | | */ |
| | | ///@{ |
| | | kOpenSDKErrorWebPage, ///< 页面错误 |
| | | ///@} |
| | | |
| | | /** |
| | | * \name SetUserHeadRelatedErrorCode |
| | | * 设置头像自定义错误码段 |
| | | */ |
| | | ///@{ |
| | | kOpenSDKErrorUserHeadPicLarge = 0x010000, ///< 图片过大 设置头像自定义错误码 |
| | | ///@} |
| | | } OpenSDKError; |
| | | |
| | | /** |
| | | * \name SDK版本(v1.3)支持的授权列表常量 |
| | | */ |
| | | ///@{ |
| | | |
| | | /** 发表一条说说到QQ空间(<b>需要申请权限</b>) */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_TOPIC; |
| | | |
| | | /** 发表一篇日志到QQ空间(<b>需要申请权限</b>) */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_ONE_BLOG; |
| | | |
| | | /** 创建一个QQ空间相册(<b>需要申请权限</b>) */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_ALBUM; |
| | | |
| | | /** 上传一张照片到QQ空间相册(<b>需要申请权限</b>) */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_UPLOAD_PIC; |
| | | |
| | | /** 获取用户QQ空间相册列表(<b>需要申请权限</b>) */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_LIST_ALBUM; |
| | | |
| | | /** 同步分享到QQ空间、腾讯微博 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_SHARE; |
| | | |
| | | /** 验证是否认证空间粉丝 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_CHECK_PAGE_FANS; |
| | | |
| | | /** 获取登录用户自己的详细信息 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_INFO; |
| | | |
| | | /** 获取其他用户的详细信息 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_OTHER_INFO; |
| | | |
| | | /** 获取会员用户基本信息 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_VIP_INFO; |
| | | |
| | | /** 获取会员用户详细信息 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_VIP_RICH_INFO; |
| | | |
| | | /** 获取用户信息 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_USER_INFO; |
| | | |
| | | /** 移动端获取用户信息 */ |
| | | FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_SIMPLE_USER_INFO; |
| | | ///@} |
| | | |
| | | |
| | | /** |
| | | * \name CGI接口相关参数类型定义 |
| | | */ |
| | | ///@{ |
| | | |
| | | /** 必填的字符串类型参数 */ |
| | | typedef NSString *TCRequiredStr; |
| | | |
| | | /** 必填的UIImage类型参数 */ |
| | | typedef UIImage *TCRequiredImage; |
| | | |
| | | /** 必填的整型参数 */ |
| | | typedef NSInteger TCRequiredInt; |
| | | |
| | | /** 必填的数字类型 */ |
| | | typedef NSNumber *TCRequiredNumber; |
| | | |
| | | /** 必填的NSData参数 */ |
| | | typedef NSData *TCRequiredData; |
| | | |
| | | /** 可选的字符串类型参数 */ |
| | | typedef NSString *TCOptionalStr; |
| | | |
| | | /** 可选的UIImage类型参数 */ |
| | | typedef UIImage *TCOptionalImage; |
| | | |
| | | /** 可选的整型参数 */ |
| | | typedef NSInteger TCOptionalInt; |
| | | |
| | | /** 可选的数字类型 */ |
| | | typedef NSNumber *TCOptionalNumber; |
| | | |
| | | /** 可选的不定类型参数 */ |
| | | typedef id TCRequiredId; |
| | | ///@} |
| | | |
| | | |
| | | /** |
| | | * \brief CGI请求的参数字典封装辅助基类 |
| | | * |
| | | * 将相应属性的值以key-value的形式保存到参数字典中 |
| | | */ |
| | | @interface TCAPIRequest : NSMutableDictionary |
| | | |
| | | /** CGI请求的URL地址 */ |
| | | @property (nonatomic, readonly) NSURL *apiURL; |
| | | |
| | | /** CGI请求方式:"GET","POST" */ |
| | | @property (nonatomic, readonly) NSString *method; |
| | | |
| | | /** |
| | | * API参数中的保留字段,可以塞入任意字典支持的类型,再调用完成后会带回给调用方 |
| | | */ |
| | | @property (nonatomic, retain) TCRequiredId paramUserData; |
| | | |
| | | /** |
| | | * APIResponse,API的返回结果 |
| | | */ |
| | | @property (nonatomic, readonly) APIResponse *response; |
| | | |
| | | /** 取消相应的CGI请求任务 */ |
| | | - (void)cancel; |
| | | |
| | | @end |
| | | |
| | | @protocol TCAPIRequestDelegate <NSObject> |
| | | @optional |
| | | - (void)cgiRequest:(TCAPIRequest *)request didResponse:(APIResponse *)response; |
| | | |
| | | @end |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| | | <plist version="1.0"> |
| | | <dict> |
| | | <key>WANCMS_GAMEID</key> |
| | | <string>1</string> |
| | | <key>WANCMS_APPID</key> |
| | | <string>1</string> |
| | | <key>WANCMS_AGENT</key> |
| | | <string>cps001</string> |
| | | </dict> |
| | | </plist> |
New file |
| | |
| | | // |
| | | // BuglyBridge.h |
| | | // BuglyAgent |
| | | // |
| | | // Created by Yeelik on 15/11/25. |
| | | // Copyright © 2015年 Bugly. All rights reserved. |
| | | // |
| | | // Version: 1.3.3 |
| | | // |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | |
| | | #pragma mark - Interface for Bridge |
| | | |
| | | #ifdef __cplusplus |
| | | extern "C"{ |
| | | #endif |
| | | |
| | | /** |
| | | * @brief 初始化 |
| | | * |
| | | * @param appId 应用标识 |
| | | * @param debug 是否开启debug模式,开启后会在控制台打印调试信息,默认为NO |
| | | * @param level 自定义日志上报级别,使用SDK接口打印的日志会跟崩溃信息一起上报,默认为Info(即Info、Warning、Error级别的日志都会上报) |
| | | * Debug=4,Info=3,Warnning=2,Error=1,Off=0 |
| | | */ |
| | | void _BuglyInit(const char * appId, bool debug, int level); |
| | | |
| | | /** |
| | | * @brief 设置用户唯一标识 |
| | | * |
| | | * @param userId |
| | | */ |
| | | void _BuglySetUserId(const char * userId); |
| | | |
| | | /** |
| | | * @brief 设置自定义标签 |
| | | * |
| | | * @param tag |
| | | */ |
| | | void _BuglySetTag(int tag); |
| | | |
| | | /** |
| | | * @brief 设置自定义键值对数据 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | void _BuglySetKeyValue(const char * key, const char * value); |
| | | |
| | | /** |
| | | * @brief 自定义异常数据上报 |
| | | * |
| | | * @param type |
| | | * @param name 异常类型 |
| | | * @param reason 异常原因 |
| | | * @param stackTrace 异常堆栈 |
| | | * @param extras 附加数据 |
| | | * @param quit 上报后是否退出应用 |
| | | */ |
| | | void _BuglyReportException(int type, const char * name, const char * reason, const char * stackTrace, const char * extras, bool quit); |
| | | |
| | | /** |
| | | * @brief 设置默认的应用配置,在初始化之前调用 |
| | | * |
| | | * @param channel 渠道 |
| | | * @param version 应用版本 |
| | | * @param user 用户 |
| | | * @param deviceId 设备唯一标识 |
| | | */ |
| | | void _BuglyDefaultConfig(const char * channel, const char * version, const char *user, const char * deviceId); |
| | | |
| | | /** |
| | | * @brief 自定义日志打印接口 |
| | | * |
| | | * @param level 日志级别, 1=Error、2=Warning、3=Info、4=Debug |
| | | * @param tag 日志标签 |
| | | * @param log 日志内容 |
| | | */ |
| | | void _BuglyLogMessage(int level, const char * tag, const char * log); |
| | | |
| | | /** |
| | | * @brief 设置崩溃上报组件的类别 |
| | | * |
| | | * @param type 0=Default、1=Bugly、2=MSDK、3=IMSDK |
| | | */ |
| | | void _BuglyConfigCrashReporterType(int type); |
| | | |
| | | /** |
| | | * @brief 设置额外的配置信息 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | void _BuglySetExtraConfig(const char *key, const char * value); |
| | | |
| | | #ifdef __cplusplus |
| | | } // extern "C" |
| | | #endif |
| | | |
| | | #pragma mark - |
New file |
| | |
| | | /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited |
| | | Written by Jean-Marc Valin and Koen Vos */ |
| | | /* |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions |
| | | are met: |
| | | |
| | | - Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | |
| | | - Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| | | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| | | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | |
| | | /** |
| | | * @file opus.h |
| | | * @brief Opus reference implementation API |
| | | */ |
| | | |
| | | #ifndef OPUS_H |
| | | #define OPUS_H |
| | | |
| | | #include "opus_types.h" |
| | | #include "opus_defines.h" |
| | | |
| | | #ifdef __cplusplus |
| | | extern "C" { |
| | | #endif |
| | | |
| | | /** |
| | | * @mainpage Opus |
| | | * |
| | | * The Opus codec is designed for interactive speech and audio transmission over the Internet. |
| | | * It is designed by the IETF Codec Working Group and incorporates technology from |
| | | * Skype's SILK codec and Xiph.Org's CELT codec. |
| | | * |
| | | * The Opus codec is designed to handle a wide range of interactive audio applications, |
| | | * including Voice over IP, videoconferencing, in-game chat, and even remote live music |
| | | * performances. It can scale from low bit-rate narrowband speech to very high quality |
| | | * stereo music. Its main features are: |
| | | |
| | | * @li Sampling rates from 8 to 48 kHz |
| | | * @li Bit-rates from 6 kb/s to 510 kb/s |
| | | * @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) |
| | | * @li Audio bandwidth from narrowband to full-band |
| | | * @li Support for speech and music |
| | | * @li Support for mono and stereo |
| | | * @li Support for multichannel (up to 255 channels) |
| | | * @li Frame sizes from 2.5 ms to 60 ms |
| | | * @li Good loss robustness and packet loss concealment (PLC) |
| | | * @li Floating point and fixed-point implementation |
| | | * |
| | | * Documentation sections: |
| | | * @li @ref opus_encoder |
| | | * @li @ref opus_decoder |
| | | * @li @ref opus_repacketizer |
| | | * @li @ref opus_multistream |
| | | * @li @ref opus_libinfo |
| | | * @li @ref opus_custom |
| | | */ |
| | | |
| | | /** @defgroup opus_encoder Opus Encoder |
| | | * @{ |
| | | * |
| | | * @brief This page describes the process and functions used to encode Opus. |
| | | * |
| | | * Since Opus is a stateful codec, the encoding process starts with creating an encoder |
| | | * state. This can be done with: |
| | | * |
| | | * @code |
| | | * int error; |
| | | * OpusEncoder *enc; |
| | | * enc = opus_encoder_create(Fs, channels, application, &error); |
| | | * @endcode |
| | | * |
| | | * From this point, @c enc can be used for encoding an audio stream. An encoder state |
| | | * @b must @b not be used for more than one stream at the same time. Similarly, the encoder |
| | | * state @b must @b not be re-initialized for each frame. |
| | | * |
| | | * While opus_encoder_create() allocates memory for the state, it's also possible |
| | | * to initialize pre-allocated memory: |
| | | * |
| | | * @code |
| | | * int size; |
| | | * int error; |
| | | * OpusEncoder *enc; |
| | | * size = opus_encoder_get_size(channels); |
| | | * enc = malloc(size); |
| | | * error = opus_encoder_init(enc, Fs, channels, application); |
| | | * @endcode |
| | | * |
| | | * where opus_encoder_get_size() returns the required size for the encoder state. Note that |
| | | * future versions of this code may change the size, so no assuptions should be made about it. |
| | | * |
| | | * The encoder state is always continuous in memory and only a shallow copy is sufficient |
| | | * to copy it (e.g. memcpy()) |
| | | * |
| | | * It is possible to change some of the encoder's settings using the opus_encoder_ctl() |
| | | * interface. All these settings already default to the recommended value, so they should |
| | | * only be changed when necessary. The most common settings one may want to change are: |
| | | * |
| | | * @code |
| | | * opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate)); |
| | | * opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); |
| | | * opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); |
| | | * @endcode |
| | | * |
| | | * where |
| | | * |
| | | * @arg bitrate is in bits per second (b/s) |
| | | * @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest |
| | | * @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC |
| | | * |
| | | * See @ref opus_encoderctls and @ref opus_genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream. |
| | | * |
| | | * To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: |
| | | * @code |
| | | * len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); |
| | | * @endcode |
| | | * |
| | | * where |
| | | * <ul> |
| | | * <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li> |
| | | * <li>frame_size is the duration of the frame in samples (per channel)</li> |
| | | * <li>packet is the byte array to which the compressed data is written</li> |
| | | * <li>max_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended). |
| | | * Do not use max_packet to control VBR target bitrate, instead use the #OPUS_SET_BITRATE CTL.</li> |
| | | * </ul> |
| | | * |
| | | * opus_encode() and opus_encode_float() return the number of bytes actually written to the packet. |
| | | * The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value |
| | | * is 2 bytes or less, then the packet does not need to be transmitted (DTX). |
| | | * |
| | | * Once the encoder state if no longer needed, it can be destroyed with |
| | | * |
| | | * @code |
| | | * opus_encoder_destroy(enc); |
| | | * @endcode |
| | | * |
| | | * If the encoder was created with opus_encoder_init() rather than opus_encoder_create(), |
| | | * then no action is required aside from potentially freeing the memory that was manually |
| | | * allocated for it (calling free(enc) for the example above) |
| | | * |
| | | */ |
| | | |
| | | /** Opus encoder state. |
| | | * This contains the complete state of an Opus encoder. |
| | | * It is position independent and can be freely copied. |
| | | * @see opus_encoder_create,opus_encoder_init |
| | | */ |
| | | typedef struct OpusEncoder OpusEncoder; |
| | | |
| | | /** Gets the size of an <code>OpusEncoder</code> structure. |
| | | * @param[in] channels <tt>int</tt>: Number of channels. |
| | | * This must be 1 or 2. |
| | | * @returns The size in bytes. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels); |
| | | |
| | | /** |
| | | */ |
| | | |
| | | /** Allocates and initializes an encoder state. |
| | | * There are three coding modes: |
| | | * |
| | | * @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice |
| | | * signals. It enhances the input signal by high-pass filtering and |
| | | * emphasizing formants and harmonics. Optionally it includes in-band |
| | | * forward error correction to protect against packet loss. Use this |
| | | * mode for typical VoIP applications. Because of the enhancement, |
| | | * even at high bitrates the output may sound different from the input. |
| | | * |
| | | * @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most |
| | | * non-voice signals like music. Use this mode for music and mixed |
| | | * (music/voice) content, broadcast, and applications requiring less |
| | | * than 15 ms of coding delay. |
| | | * |
| | | * @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that |
| | | * disables the speech-optimized mode in exchange for slightly reduced delay. |
| | | * This mode can only be set on an newly initialized or freshly reset encoder |
| | | * because it changes the codec delay. |
| | | * |
| | | * This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution). |
| | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
| | | * @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
| | | * @param [out] error <tt>int*</tt>: @ref opus_errorcodes |
| | | * @note Regardless of the sampling rate and number channels selected, the Opus encoder |
| | | * can switch to a lower audio bandwidth or number of channels if the bitrate |
| | | * selected is too low. This also means that it is safe to always use 48 kHz stereo input |
| | | * and let the encoder optimize the encoding. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int application, |
| | | int *error |
| | | ); |
| | | |
| | | /** Initializes a previously allocated encoder state |
| | | * The memory pointed to by st must be at least the size returned by opus_encoder_get_size(). |
| | | * This is intended for applications which use their own allocator instead of malloc. |
| | | * @see opus_encoder_create(),opus_encoder_get_size() |
| | | * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
| | | * @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
| | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
| | | * @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
| | | * @retval #OPUS_OK Success or @ref opus_errorcodes |
| | | */ |
| | | OPUS_EXPORT int opus_encoder_init( |
| | | OpusEncoder *st, |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int application |
| | | ) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Encodes an Opus frame. |
| | | * @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
| | | * @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16) |
| | | * @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
| | | * input signal. |
| | | * This must be an Opus frame size for |
| | | * the encoder's sampling rate. |
| | | * For example, at 48 kHz the permitted |
| | | * values are 120, 240, 480, 960, 1920, |
| | | * and 2880. |
| | | * Passing in a duration of less than |
| | | * 10 ms (480 samples at 48 kHz) will |
| | | * prevent the encoder from using the LPC |
| | | * or hybrid modes. |
| | | * @param [out] data <tt>unsigned char*</tt>: Output payload. |
| | | * This must contain storage for at |
| | | * least \a max_data_bytes. |
| | | * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
| | | * memory for the output |
| | | * payload. This may be |
| | | * used to impose an upper limit on |
| | | * the instant bitrate, but should |
| | | * not be used as the only bitrate |
| | | * control. Use #OPUS_SET_BITRATE to |
| | | * control the bitrate. |
| | | * @returns The length of the encoded packet (in bytes) on success or a |
| | | * negative error code (see @ref opus_errorcodes) on failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( |
| | | OpusEncoder *st, |
| | | const opus_int16 *pcm, |
| | | int frame_size, |
| | | unsigned char *data, |
| | | opus_int32 max_data_bytes |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Encodes an Opus frame from floating point input. |
| | | * @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
| | | * @param [in] pcm <tt>float*</tt>: Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. |
| | | * Samples with a range beyond +/-1.0 are supported but will |
| | | * be clipped by decoders using the integer API and should |
| | | * only be used if it is known that the far end supports |
| | | * extended dynamic range. |
| | | * length is frame_size*channels*sizeof(float) |
| | | * @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
| | | * input signal. |
| | | * This must be an Opus frame size for |
| | | * the encoder's sampling rate. |
| | | * For example, at 48 kHz the permitted |
| | | * values are 120, 240, 480, 960, 1920, |
| | | * and 2880. |
| | | * Passing in a duration of less than |
| | | * 10 ms (480 samples at 48 kHz) will |
| | | * prevent the encoder from using the LPC |
| | | * or hybrid modes. |
| | | * @param [out] data <tt>unsigned char*</tt>: Output payload. |
| | | * This must contain storage for at |
| | | * least \a max_data_bytes. |
| | | * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
| | | * memory for the output |
| | | * payload. This may be |
| | | * used to impose an upper limit on |
| | | * the instant bitrate, but should |
| | | * not be used as the only bitrate |
| | | * control. Use #OPUS_SET_BITRATE to |
| | | * control the bitrate. |
| | | * @returns The length of the encoded packet (in bytes) on success or a |
| | | * negative error code (see @ref opus_errorcodes) on failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float( |
| | | OpusEncoder *st, |
| | | const float *pcm, |
| | | int frame_size, |
| | | unsigned char *data, |
| | | opus_int32 max_data_bytes |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Frees an <code>OpusEncoder</code> allocated by opus_encoder_create(). |
| | | * @param[in] st <tt>OpusEncoder*</tt>: State to be freed. |
| | | */ |
| | | OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); |
| | | |
| | | /** Perform a CTL function on an Opus encoder. |
| | | * |
| | | * Generally the request and subsequent arguments are generated |
| | | * by a convenience macro. |
| | | * @param st <tt>OpusEncoder*</tt>: Encoder state. |
| | | * @param request This and all remaining parameters should be replaced by one |
| | | * of the convenience macros in @ref opus_genericctls or |
| | | * @ref opus_encoderctls. |
| | | * @see opus_genericctls |
| | | * @see opus_encoderctls |
| | | */ |
| | | OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
| | | /**@}*/ |
| | | |
| | | /** @defgroup opus_decoder Opus Decoder |
| | | * @{ |
| | | * |
| | | * @brief This page describes the process and functions used to decode Opus. |
| | | * |
| | | * The decoding process also starts with creating a decoder |
| | | * state. This can be done with: |
| | | * @code |
| | | * int error; |
| | | * OpusDecoder *dec; |
| | | * dec = opus_decoder_create(Fs, channels, &error); |
| | | * @endcode |
| | | * where |
| | | * @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000 |
| | | * @li channels is the number of channels (1 or 2) |
| | | * @li error will hold the error code in case of failure (or #OPUS_OK on success) |
| | | * @li the return value is a newly created decoder state to be used for decoding |
| | | * |
| | | * While opus_decoder_create() allocates memory for the state, it's also possible |
| | | * to initialize pre-allocated memory: |
| | | * @code |
| | | * int size; |
| | | * int error; |
| | | * OpusDecoder *dec; |
| | | * size = opus_decoder_get_size(channels); |
| | | * dec = malloc(size); |
| | | * error = opus_decoder_init(dec, Fs, channels); |
| | | * @endcode |
| | | * where opus_decoder_get_size() returns the required size for the decoder state. Note that |
| | | * future versions of this code may change the size, so no assuptions should be made about it. |
| | | * |
| | | * The decoder state is always continuous in memory and only a shallow copy is sufficient |
| | | * to copy it (e.g. memcpy()) |
| | | * |
| | | * To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data: |
| | | * @code |
| | | * frame_size = opus_decode(dec, packet, len, decoded, max_size, 0); |
| | | * @endcode |
| | | * where |
| | | * |
| | | * @li packet is the byte array containing the compressed data |
| | | * @li len is the exact number of bytes contained in the packet |
| | | * @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float()) |
| | | * @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array |
| | | * |
| | | * opus_decode() and opus_decode_float() return the number of samples (per channel) decoded from the packet. |
| | | * If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio |
| | | * buffer is too small to hold the decoded audio. |
| | | * |
| | | * Opus is a stateful codec with overlapping blocks and as a result Opus |
| | | * packets are not coded independently of each other. Packets must be |
| | | * passed into the decoder serially and in the correct order for a correct |
| | | * decode. Lost packets can be replaced with loss concealment by calling |
| | | * the decoder with a null pointer and zero length for the missing packet. |
| | | * |
| | | * A single codec state may only be accessed from a single thread at |
| | | * a time and any required locking must be performed by the caller. Separate |
| | | * streams must be decoded with separate decoder states and can be decoded |
| | | * in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK |
| | | * defined. |
| | | * |
| | | */ |
| | | |
| | | /** Opus decoder state. |
| | | * This contains the complete state of an Opus decoder. |
| | | * It is position independent and can be freely copied. |
| | | * @see opus_decoder_create,opus_decoder_init |
| | | */ |
| | | typedef struct OpusDecoder OpusDecoder; |
| | | |
| | | /** Gets the size of an <code>OpusDecoder</code> structure. |
| | | * @param [in] channels <tt>int</tt>: Number of channels. |
| | | * This must be 1 or 2. |
| | | * @returns The size in bytes. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels); |
| | | |
| | | /** Allocates and initializes a decoder state. |
| | | * @param [in] Fs <tt>opus_int32</tt>: Sample rate to decode at (Hz). |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
| | | * @param [out] error <tt>int*</tt>: #OPUS_OK Success or @ref opus_errorcodes |
| | | * |
| | | * Internally Opus stores data at 48000 Hz, so that should be the default |
| | | * value for Fs. However, the decoder can efficiently decode to buffers |
| | | * at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use |
| | | * data at the full sample rate, or knows the compressed data doesn't |
| | | * use the full frequency range, it can request decoding at a reduced |
| | | * rate. Likewise, the decoder is capable of filling in either mono or |
| | | * interleaved stereo pcm buffers, at the caller's request. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int *error |
| | | ); |
| | | |
| | | /** Initializes a previously allocated decoder state. |
| | | * The state must be at least the size returned by opus_decoder_get_size(). |
| | | * This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size |
| | | * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
| | | * @param [in] st <tt>OpusDecoder*</tt>: Decoder state. |
| | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate to decode to (Hz). |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
| | | * @retval #OPUS_OK Success or @ref opus_errorcodes |
| | | */ |
| | | OPUS_EXPORT int opus_decoder_init( |
| | | OpusDecoder *st, |
| | | opus_int32 Fs, |
| | | int channels |
| | | ) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Decode an Opus packet. |
| | | * @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
| | | * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
| | | * @param [in] len <tt>opus_int32</tt>: Number of bytes in payload* |
| | | * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length |
| | | * is frame_size*channels*sizeof(opus_int16) |
| | | * @param [in] frame_size Number of samples per channel of available space in \a pcm. |
| | | * If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
| | | * not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
| | | * then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
| | | * decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
| | | * FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
| | | * @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
| | | * decoded. If no such data is available, the frame is decoded as if it were lost. |
| | | * @returns Number of decoded samples or @ref opus_errorcodes |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode( |
| | | OpusDecoder *st, |
| | | const unsigned char *data, |
| | | opus_int32 len, |
| | | opus_int16 *pcm, |
| | | int frame_size, |
| | | int decode_fec |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Decode an Opus packet with floating point output. |
| | | * @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
| | | * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
| | | * @param [in] len <tt>opus_int32</tt>: Number of bytes in payload |
| | | * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length |
| | | * is frame_size*channels*sizeof(float) |
| | | * @param [in] frame_size Number of samples per channel of available space in \a pcm. |
| | | * If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
| | | * not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
| | | * then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
| | | * decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
| | | * FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
| | | * @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
| | | * decoded. If no such data is available the frame is decoded as if it were lost. |
| | | * @returns Number of decoded samples or @ref opus_errorcodes |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float( |
| | | OpusDecoder *st, |
| | | const unsigned char *data, |
| | | opus_int32 len, |
| | | float *pcm, |
| | | int frame_size, |
| | | int decode_fec |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Perform a CTL function on an Opus decoder. |
| | | * |
| | | * Generally the request and subsequent arguments are generated |
| | | * by a convenience macro. |
| | | * @param st <tt>OpusDecoder*</tt>: Decoder state. |
| | | * @param request This and all remaining parameters should be replaced by one |
| | | * of the convenience macros in @ref opus_genericctls or |
| | | * @ref opus_decoderctls. |
| | | * @see opus_genericctls |
| | | * @see opus_decoderctls |
| | | */ |
| | | OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Frees an <code>OpusDecoder</code> allocated by opus_decoder_create(). |
| | | * @param[in] st <tt>OpusDecoder*</tt>: State to be freed. |
| | | */ |
| | | OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); |
| | | |
| | | /** Parse an opus packet into one or more frames. |
| | | * Opus_decode will perform this operation internally so most applications do |
| | | * not need to use this function. |
| | | * This function does not copy the frames, the returned pointers are pointers into |
| | | * the input packet. |
| | | * @param [in] data <tt>char*</tt>: Opus packet to be parsed |
| | | * @param [in] len <tt>opus_int32</tt>: size of data |
| | | * @param [out] out_toc <tt>char*</tt>: TOC pointer |
| | | * @param [out] frames <tt>char*[48]</tt> encapsulated frames |
| | | * @param [out] size <tt>opus_int16[48]</tt> sizes of the encapsulated frames |
| | | * @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes) |
| | | * @returns number of frames |
| | | */ |
| | | OPUS_EXPORT int opus_packet_parse( |
| | | const unsigned char *data, |
| | | opus_int32 len, |
| | | unsigned char *out_toc, |
| | | const unsigned char *frames[48], |
| | | opus_int16 size[48], |
| | | int *payload_offset |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Gets the bandwidth of an Opus packet. |
| | | * @param [in] data <tt>char*</tt>: Opus packet |
| | | * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) |
| | | * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) |
| | | * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) |
| | | * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) |
| | | * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) |
| | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Gets the number of samples per frame from an Opus packet. |
| | | * @param [in] data <tt>char*</tt>: Opus packet. |
| | | * This must contain at least one byte of |
| | | * data. |
| | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
| | | * This must be a multiple of 400, or |
| | | * inaccurate results will be returned. |
| | | * @returns Number of samples per frame. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Gets the number of channels from an Opus packet. |
| | | * @param [in] data <tt>char*</tt>: Opus packet |
| | | * @returns Number of channels |
| | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Gets the number of frames in an Opus packet. |
| | | * @param [in] packet <tt>char*</tt>: Opus packet |
| | | * @param [in] len <tt>opus_int32</tt>: Length of packet |
| | | * @returns Number of frames |
| | | * @retval OPUS_BAD_ARG Insufficient data was passed to the function |
| | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Gets the number of samples of an Opus packet. |
| | | * @param [in] packet <tt>char*</tt>: Opus packet |
| | | * @param [in] len <tt>opus_int32</tt>: Length of packet |
| | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
| | | * This must be a multiple of 400, or |
| | | * inaccurate results will be returned. |
| | | * @returns Number of samples |
| | | * @retval OPUS_BAD_ARG Insufficient data was passed to the function |
| | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Gets the number of samples of an Opus packet. |
| | | * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state |
| | | * @param [in] packet <tt>char*</tt>: Opus packet |
| | | * @param [in] len <tt>opus_int32</tt>: Length of packet |
| | | * @returns Number of samples |
| | | * @retval OPUS_BAD_ARG Insufficient data was passed to the function |
| | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
| | | |
| | | /** Applies soft-clipping to bring a float signal within the [-1,1] range. If |
| | | * the signal is already in that range, nothing is done. If there are values |
| | | * outside of [-1,1], then the signal is clipped as smoothly as possible to |
| | | * both fit in the range and avoid creating excessive distortion in the |
| | | * process. |
| | | * @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM |
| | | * @param [in] frame_size <tt>int</tt> Number of samples per channel to process |
| | | * @param [in] channels <tt>int</tt>: Number of channels |
| | | * @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clipping process (one float per channel, initialized to zero) |
| | | */ |
| | | OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem); |
| | | |
| | | |
| | | /**@}*/ |
| | | |
| | | /** @defgroup opus_repacketizer Repacketizer |
| | | * @{ |
| | | * |
| | | * The repacketizer can be used to merge multiple Opus packets into a single |
| | | * packet or alternatively to split Opus packets that have previously been |
| | | * merged. Splitting valid Opus packets is always guaranteed to succeed, |
| | | * whereas merging valid packets only succeeds if all frames have the same |
| | | * mode, bandwidth, and frame size, and when the total duration of the merged |
| | | * packet is no more than 120 ms. The 120 ms limit comes from the |
| | | * specification and limits decoder memory requirements at a point where |
| | | * framing overhead becomes negligible. |
| | | * |
| | | * The repacketizer currently only operates on elementary Opus |
| | | * streams. It will not manipualte multistream packets successfully, except in |
| | | * the degenerate case where they consist of data from a single stream. |
| | | * |
| | | * The repacketizing process starts with creating a repacketizer state, either |
| | | * by calling opus_repacketizer_create() or by allocating the memory yourself, |
| | | * e.g., |
| | | * @code |
| | | * OpusRepacketizer *rp; |
| | | * rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size()); |
| | | * if (rp != NULL) |
| | | * opus_repacketizer_init(rp); |
| | | * @endcode |
| | | * |
| | | * Then the application should submit packets with opus_repacketizer_cat(), |
| | | * extract new packets with opus_repacketizer_out() or |
| | | * opus_repacketizer_out_range(), and then reset the state for the next set of |
| | | * input packets via opus_repacketizer_init(). |
| | | * |
| | | * For example, to split a sequence of packets into individual frames: |
| | | * @code |
| | | * unsigned char *data; |
| | | * int len; |
| | | * while (get_next_packet(&data, &len)) |
| | | * { |
| | | * unsigned char out[1276]; |
| | | * opus_int32 out_len; |
| | | * int nb_frames; |
| | | * int err; |
| | | * int i; |
| | | * err = opus_repacketizer_cat(rp, data, len); |
| | | * if (err != OPUS_OK) |
| | | * { |
| | | * release_packet(data); |
| | | * return err; |
| | | * } |
| | | * nb_frames = opus_repacketizer_get_nb_frames(rp); |
| | | * for (i = 0; i < nb_frames; i++) |
| | | * { |
| | | * out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out)); |
| | | * if (out_len < 0) |
| | | * { |
| | | * release_packet(data); |
| | | * return (int)out_len; |
| | | * } |
| | | * output_next_packet(out, out_len); |
| | | * } |
| | | * opus_repacketizer_init(rp); |
| | | * release_packet(data); |
| | | * } |
| | | * @endcode |
| | | * |
| | | * Alternatively, to combine a sequence of frames into packets that each |
| | | * contain up to <code>TARGET_DURATION_MS</code> milliseconds of data: |
| | | * @code |
| | | * // The maximum number of packets with duration TARGET_DURATION_MS occurs |
| | | * // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5) |
| | | * // packets. |
| | | * unsigned char *data[(TARGET_DURATION_MS*2/5)+1]; |
| | | * opus_int32 len[(TARGET_DURATION_MS*2/5)+1]; |
| | | * int nb_packets; |
| | | * unsigned char out[1277*(TARGET_DURATION_MS*2/2)]; |
| | | * opus_int32 out_len; |
| | | * int prev_toc; |
| | | * nb_packets = 0; |
| | | * while (get_next_packet(data+nb_packets, len+nb_packets)) |
| | | * { |
| | | * int nb_frames; |
| | | * int err; |
| | | * nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]); |
| | | * if (nb_frames < 1) |
| | | * { |
| | | * release_packets(data, nb_packets+1); |
| | | * return nb_frames; |
| | | * } |
| | | * nb_frames += opus_repacketizer_get_nb_frames(rp); |
| | | * // If adding the next packet would exceed our target, or it has an |
| | | * // incompatible TOC sequence, output the packets we already have before |
| | | * // submitting it. |
| | | * // N.B., The nb_packets > 0 check ensures we've submitted at least one |
| | | * // packet since the last call to opus_repacketizer_init(). Otherwise a |
| | | * // single packet longer than TARGET_DURATION_MS would cause us to try to |
| | | * // output an (invalid) empty packet. It also ensures that prev_toc has |
| | | * // been set to a valid value. Additionally, len[nb_packets] > 0 is |
| | | * // guaranteed by the call to opus_packet_get_nb_frames() above, so the |
| | | * // reference to data[nb_packets][0] should be valid. |
| | | * if (nb_packets > 0 && ( |
| | | * ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) || |
| | | * opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames > |
| | | * TARGET_DURATION_MS*48)) |
| | | * { |
| | | * out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
| | | * if (out_len < 0) |
| | | * { |
| | | * release_packets(data, nb_packets+1); |
| | | * return (int)out_len; |
| | | * } |
| | | * output_next_packet(out, out_len); |
| | | * opus_repacketizer_init(rp); |
| | | * release_packets(data, nb_packets); |
| | | * data[0] = data[nb_packets]; |
| | | * len[0] = len[nb_packets]; |
| | | * nb_packets = 0; |
| | | * } |
| | | * err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]); |
| | | * if (err != OPUS_OK) |
| | | * { |
| | | * release_packets(data, nb_packets+1); |
| | | * return err; |
| | | * } |
| | | * prev_toc = data[nb_packets][0]; |
| | | * nb_packets++; |
| | | * } |
| | | * // Output the final, partial packet. |
| | | * if (nb_packets > 0) |
| | | * { |
| | | * out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
| | | * release_packets(data, nb_packets); |
| | | * if (out_len < 0) |
| | | * return (int)out_len; |
| | | * output_next_packet(out, out_len); |
| | | * } |
| | | * @endcode |
| | | * |
| | | * An alternate way of merging packets is to simply call opus_repacketizer_cat() |
| | | * unconditionally until it fails. At that point, the merged packet can be |
| | | * obtained with opus_repacketizer_out() and the input packet for which |
| | | * opus_repacketizer_cat() needs to be re-added to a newly reinitialized |
| | | * repacketizer state. |
| | | */ |
| | | |
| | | typedef struct OpusRepacketizer OpusRepacketizer; |
| | | |
| | | /** Gets the size of an <code>OpusRepacketizer</code> structure. |
| | | * @returns The size in bytes. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void); |
| | | |
| | | /** (Re)initializes a previously allocated repacketizer state. |
| | | * The state must be at least the size returned by opus_repacketizer_get_size(). |
| | | * This can be used for applications which use their own allocator instead of |
| | | * malloc(). |
| | | * It must also be called to reset the queue of packets waiting to be |
| | | * repacketized, which is necessary if the maximum packet duration of 120 ms |
| | | * is reached or if you wish to submit packets with a different Opus |
| | | * configuration (coding mode, audio bandwidth, frame size, or channel count). |
| | | * Failure to do so will prevent a new packet from being added with |
| | | * opus_repacketizer_cat(). |
| | | * @see opus_repacketizer_create |
| | | * @see opus_repacketizer_get_size |
| | | * @see opus_repacketizer_cat |
| | | * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to |
| | | * (re)initialize. |
| | | * @returns A pointer to the same repacketizer state that was passed in. |
| | | */ |
| | | OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Allocates memory and initializes the new repacketizer with |
| | | * opus_repacketizer_init(). |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void); |
| | | |
| | | /** Frees an <code>OpusRepacketizer</code> allocated by |
| | | * opus_repacketizer_create(). |
| | | * @param[in] rp <tt>OpusRepacketizer*</tt>: State to be freed. |
| | | */ |
| | | OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); |
| | | |
| | | /** Add a packet to the current repacketizer state. |
| | | * This packet must match the configuration of any packets already submitted |
| | | * for repacketization since the last call to opus_repacketizer_init(). |
| | | * This means that it must have the same coding mode, audio bandwidth, frame |
| | | * size, and channel count. |
| | | * This can be checked in advance by examining the top 6 bits of the first |
| | | * byte of the packet, and ensuring they match the top 6 bits of the first |
| | | * byte of any previously submitted packet. |
| | | * The total duration of audio in the repacketizer state also must not exceed |
| | | * 120 ms, the maximum duration of a single packet, after adding this packet. |
| | | * |
| | | * The contents of the current repacketizer state can be extracted into new |
| | | * packets using opus_repacketizer_out() or opus_repacketizer_out_range(). |
| | | * |
| | | * In order to add a packet with a different configuration or to add more |
| | | * audio beyond 120 ms, you must clear the repacketizer state by calling |
| | | * opus_repacketizer_init(). |
| | | * If a packet is too large to add to the current repacketizer state, no part |
| | | * of it is added, even if it contains multiple frames, some of which might |
| | | * fit. |
| | | * If you wish to be able to add parts of such packets, you should first use |
| | | * another repacketizer to split the packet into pieces and add them |
| | | * individually. |
| | | * @see opus_repacketizer_out_range |
| | | * @see opus_repacketizer_out |
| | | * @see opus_repacketizer_init |
| | | * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to which to |
| | | * add the packet. |
| | | * @param[in] data <tt>const unsigned char*</tt>: The packet data. |
| | | * The application must ensure |
| | | * this pointer remains valid |
| | | * until the next call to |
| | | * opus_repacketizer_init() or |
| | | * opus_repacketizer_destroy(). |
| | | * @param len <tt>opus_int32</tt>: The number of bytes in the packet data. |
| | | * @returns An error code indicating whether or not the operation succeeded. |
| | | * @retval #OPUS_OK The packet's contents have been added to the repacketizer |
| | | * state. |
| | | * @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence, |
| | | * the packet's TOC sequence was not compatible |
| | | * with previously submitted packets (because |
| | | * the coding mode, audio bandwidth, frame size, |
| | | * or channel count did not match), or adding |
| | | * this packet would increase the total amount of |
| | | * audio stored in the repacketizer state to more |
| | | * than 120 ms. |
| | | */ |
| | | OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
| | | |
| | | |
| | | /** Construct a new packet from data previously submitted to the repacketizer |
| | | * state via opus_repacketizer_cat(). |
| | | * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
| | | * construct the new packet. |
| | | * @param begin <tt>int</tt>: The index of the first frame in the current |
| | | * repacketizer state to include in the output. |
| | | * @param end <tt>int</tt>: One past the index of the last frame in the |
| | | * current repacketizer state to include in the |
| | | * output. |
| | | * @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
| | | * store the output packet. |
| | | * @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
| | | * the output buffer. In order to guarantee |
| | | * success, this should be at least |
| | | * <code>1276</code> for a single frame, |
| | | * or for multiple frames, |
| | | * <code>1277*(end-begin)</code>. |
| | | * However, <code>1*(end-begin)</code> plus |
| | | * the size of all packet data submitted to |
| | | * the repacketizer since the last call to |
| | | * opus_repacketizer_init() or |
| | | * opus_repacketizer_create() is also |
| | | * sufficient, and possibly much smaller. |
| | | * @returns The total size of the output packet on success, or an error code |
| | | * on failure. |
| | | * @retval #OPUS_BAD_ARG <code>[begin,end)</code> was an invalid range of |
| | | * frames (begin < 0, begin >= end, or end > |
| | | * opus_repacketizer_get_nb_frames()). |
| | | * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
| | | * complete output packet. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Return the total number of frames contained in packet data submitted to |
| | | * the repacketizer state so far via opus_repacketizer_cat() since the last |
| | | * call to opus_repacketizer_init() or opus_repacketizer_create(). |
| | | * This defines the valid range of packets that can be extracted with |
| | | * opus_repacketizer_out_range() or opus_repacketizer_out(). |
| | | * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state containing the |
| | | * frames. |
| | | * @returns The total number of frames contained in the packet data submitted |
| | | * to the repacketizer state. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Construct a new packet from data previously submitted to the repacketizer |
| | | * state via opus_repacketizer_cat(). |
| | | * This is a convenience routine that returns all the data submitted so far |
| | | * in a single packet. |
| | | * It is equivalent to calling |
| | | * @code |
| | | * opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp), |
| | | * data, maxlen) |
| | | * @endcode |
| | | * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
| | | * construct the new packet. |
| | | * @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
| | | * store the output packet. |
| | | * @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
| | | * the output buffer. In order to guarantee |
| | | * success, this should be at least |
| | | * <code>1277*opus_repacketizer_get_nb_frames(rp)</code>. |
| | | * However, |
| | | * <code>1*opus_repacketizer_get_nb_frames(rp)</code> |
| | | * plus the size of all packet data |
| | | * submitted to the repacketizer since the |
| | | * last call to opus_repacketizer_init() or |
| | | * opus_repacketizer_create() is also |
| | | * sufficient, and possibly much smaller. |
| | | * @returns The total size of the output packet on success, or an error code |
| | | * on failure. |
| | | * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
| | | * complete output packet. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Pads a given Opus packet to a larger size (possibly changing the TOC sequence). |
| | | * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
| | | * packet to pad. |
| | | * @param len <tt>opus_int32</tt>: The size of the packet. |
| | | * This must be at least 1. |
| | | * @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
| | | * This must be at least as large as len. |
| | | * @returns an error code |
| | | * @retval #OPUS_OK \a on success. |
| | | * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
| | | * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
| | | */ |
| | | OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len); |
| | | |
| | | /** Remove all padding from a given Opus packet and rewrite the TOC sequence to |
| | | * minimize space usage. |
| | | * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
| | | * packet to strip. |
| | | * @param len <tt>opus_int32</tt>: The size of the packet. |
| | | * This must be at least 1. |
| | | * @returns The new size of the output packet on success, or an error code |
| | | * on failure. |
| | | * @retval #OPUS_BAD_ARG \a len was less than 1. |
| | | * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len); |
| | | |
| | | /** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence). |
| | | * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
| | | * packet to pad. |
| | | * @param len <tt>opus_int32</tt>: The size of the packet. |
| | | * This must be at least 1. |
| | | * @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
| | | * This must be at least 1. |
| | | * @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
| | | * This must be at least as large as len. |
| | | * @returns an error code |
| | | * @retval #OPUS_OK \a on success. |
| | | * @retval #OPUS_BAD_ARG \a len was less than 1. |
| | | * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
| | | */ |
| | | OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams); |
| | | |
| | | /** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to |
| | | * minimize space usage. |
| | | * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
| | | * packet to strip. |
| | | * @param len <tt>opus_int32</tt>: The size of the packet. |
| | | * This must be at least 1. |
| | | * @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
| | | * This must be at least 1. |
| | | * @returns The new size of the output packet on success, or an error code |
| | | * on failure. |
| | | * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
| | | * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams); |
| | | |
| | | /**@}*/ |
| | | |
| | | #ifdef __cplusplus |
| | | } |
| | | #endif |
| | | |
| | | #endif /* OPUS_H */ |
New file |
| | |
| | | /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited |
| | | Written by Jean-Marc Valin and Koen Vos */ |
| | | /* |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions |
| | | are met: |
| | | |
| | | - Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | |
| | | - Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| | | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| | | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | |
| | | /** |
| | | * @file opus_defines.h |
| | | * @brief Opus reference implementation constants |
| | | */ |
| | | |
| | | #ifndef OPUS_DEFINES_H |
| | | #define OPUS_DEFINES_H |
| | | |
| | | #include "opus_types.h" |
| | | |
| | | #ifdef __cplusplus |
| | | extern "C" { |
| | | #endif |
| | | |
| | | /** @defgroup opus_errorcodes Error codes |
| | | * @{ |
| | | */ |
| | | /** No error @hideinitializer*/ |
| | | #define OPUS_OK 0 |
| | | /** One or more invalid/out of range arguments @hideinitializer*/ |
| | | #define OPUS_BAD_ARG -1 |
| | | /** Not enough bytes allocated in the buffer @hideinitializer*/ |
| | | #define OPUS_BUFFER_TOO_SMALL -2 |
| | | /** An internal error was detected @hideinitializer*/ |
| | | #define OPUS_INTERNAL_ERROR -3 |
| | | /** The compressed data passed is corrupted @hideinitializer*/ |
| | | #define OPUS_INVALID_PACKET -4 |
| | | /** Invalid/unsupported request number @hideinitializer*/ |
| | | #define OPUS_UNIMPLEMENTED -5 |
| | | /** An encoder or decoder structure is invalid or already freed @hideinitializer*/ |
| | | #define OPUS_INVALID_STATE -6 |
| | | /** Memory allocation has failed @hideinitializer*/ |
| | | #define OPUS_ALLOC_FAIL -7 |
| | | /**@}*/ |
| | | |
| | | /** @cond OPUS_INTERNAL_DOC */ |
| | | /**Export control for opus functions */ |
| | | |
| | | #ifndef OPUS_EXPORT |
| | | # if defined(WIN32) |
| | | # if defined(OPUS_BUILD) && defined(DLL_EXPORT) |
| | | # define OPUS_EXPORT __declspec(dllexport) |
| | | # else |
| | | # define OPUS_EXPORT |
| | | # endif |
| | | # elif defined(__GNUC__) && defined(OPUS_BUILD) |
| | | # define OPUS_EXPORT __attribute__ ((visibility ("default"))) |
| | | # else |
| | | # define OPUS_EXPORT |
| | | # endif |
| | | #endif |
| | | |
| | | # if !defined(OPUS_GNUC_PREREQ) |
| | | # if defined(__GNUC__)&&defined(__GNUC_MINOR__) |
| | | # define OPUS_GNUC_PREREQ(_maj,_min) \ |
| | | ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) |
| | | # else |
| | | # define OPUS_GNUC_PREREQ(_maj,_min) 0 |
| | | # endif |
| | | # endif |
| | | |
| | | #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
| | | # if OPUS_GNUC_PREREQ(3,0) |
| | | # define OPUS_RESTRICT __restrict__ |
| | | # elif (defined(_MSC_VER) && _MSC_VER >= 1400) |
| | | # define OPUS_RESTRICT __restrict |
| | | # else |
| | | # define OPUS_RESTRICT |
| | | # endif |
| | | #else |
| | | # define OPUS_RESTRICT restrict |
| | | #endif |
| | | |
| | | #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
| | | # if OPUS_GNUC_PREREQ(2,7) |
| | | # define OPUS_INLINE __inline__ |
| | | # elif (defined(_MSC_VER)) |
| | | # define OPUS_INLINE __inline |
| | | # else |
| | | # define OPUS_INLINE |
| | | # endif |
| | | #else |
| | | # define OPUS_INLINE inline |
| | | #endif |
| | | |
| | | /**Warning attributes for opus functions |
| | | * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out |
| | | * some paranoid null checks. */ |
| | | #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
| | | # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) |
| | | #else |
| | | # define OPUS_WARN_UNUSED_RESULT |
| | | #endif |
| | | #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
| | | # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) |
| | | #else |
| | | # define OPUS_ARG_NONNULL(_x) |
| | | #endif |
| | | |
| | | /** These are the actual Encoder CTL ID numbers. |
| | | * They should not be used directly by applications. |
| | | * In general, SETs should be even and GETs should be odd.*/ |
| | | #define OPUS_SET_APPLICATION_REQUEST 4000 |
| | | #define OPUS_GET_APPLICATION_REQUEST 4001 |
| | | #define OPUS_SET_BITRATE_REQUEST 4002 |
| | | #define OPUS_GET_BITRATE_REQUEST 4003 |
| | | #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 |
| | | #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 |
| | | #define OPUS_SET_VBR_REQUEST 4006 |
| | | #define OPUS_GET_VBR_REQUEST 4007 |
| | | #define OPUS_SET_BANDWIDTH_REQUEST 4008 |
| | | #define OPUS_GET_BANDWIDTH_REQUEST 4009 |
| | | #define OPUS_SET_COMPLEXITY_REQUEST 4010 |
| | | #define OPUS_GET_COMPLEXITY_REQUEST 4011 |
| | | #define OPUS_SET_INBAND_FEC_REQUEST 4012 |
| | | #define OPUS_GET_INBAND_FEC_REQUEST 4013 |
| | | #define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 |
| | | #define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 |
| | | #define OPUS_SET_DTX_REQUEST 4016 |
| | | #define OPUS_GET_DTX_REQUEST 4017 |
| | | #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 |
| | | #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 |
| | | #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 |
| | | #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 |
| | | #define OPUS_SET_SIGNAL_REQUEST 4024 |
| | | #define OPUS_GET_SIGNAL_REQUEST 4025 |
| | | #define OPUS_GET_LOOKAHEAD_REQUEST 4027 |
| | | /* #define OPUS_RESET_STATE 4028 */ |
| | | #define OPUS_GET_SAMPLE_RATE_REQUEST 4029 |
| | | #define OPUS_GET_FINAL_RANGE_REQUEST 4031 |
| | | #define OPUS_GET_PITCH_REQUEST 4033 |
| | | #define OPUS_SET_GAIN_REQUEST 4034 |
| | | #define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ |
| | | #define OPUS_SET_LSB_DEPTH_REQUEST 4036 |
| | | #define OPUS_GET_LSB_DEPTH_REQUEST 4037 |
| | | #define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 |
| | | #define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 |
| | | #define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 |
| | | #define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 |
| | | #define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 |
| | | |
| | | /* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ |
| | | |
| | | /* Macros to trigger compilation errors when the wrong types are provided to a CTL */ |
| | | #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) |
| | | #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) |
| | | #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) |
| | | #define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) |
| | | /** @endcond */ |
| | | |
| | | /** @defgroup opus_ctlvalues Pre-defined values for CTL interface |
| | | * @see opus_genericctls, opus_encoderctls |
| | | * @{ |
| | | */ |
| | | /* Values for the various encoder CTLs */ |
| | | #define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/ |
| | | #define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/ |
| | | |
| | | /** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most |
| | | * @hideinitializer */ |
| | | #define OPUS_APPLICATION_VOIP 2048 |
| | | /** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input |
| | | * @hideinitializer */ |
| | | #define OPUS_APPLICATION_AUDIO 2049 |
| | | /** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used. |
| | | * @hideinitializer */ |
| | | #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 |
| | | |
| | | #define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */ |
| | | #define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */ |
| | | #define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideinitializer*/ |
| | | #define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideinitializer*/ |
| | | #define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideinitializer*/ |
| | | #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideinitializer*/ |
| | | #define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideinitializer*/ |
| | | |
| | | #define OPUS_FRAMESIZE_ARG 5000 /**< Select frame size from the argument (default) */ |
| | | #define OPUS_FRAMESIZE_2_5_MS 5001 /**< Use 2.5 ms frames */ |
| | | #define OPUS_FRAMESIZE_5_MS 5002 /**< Use 5 ms frames */ |
| | | #define OPUS_FRAMESIZE_10_MS 5003 /**< Use 10 ms frames */ |
| | | #define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */ |
| | | #define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */ |
| | | #define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */ |
| | | |
| | | /**@}*/ |
| | | |
| | | |
| | | /** @defgroup opus_encoderctls Encoder related CTLs |
| | | * |
| | | * These are convenience macros for use with the \c opus_encode_ctl |
| | | * interface. They are used to generate the appropriate series of |
| | | * arguments for that call, passing the correct type, size and so |
| | | * on as expected for each particular request. |
| | | * |
| | | * Some usage examples: |
| | | * |
| | | * @code |
| | | * int ret; |
| | | * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); |
| | | * if (ret != OPUS_OK) return ret; |
| | | * |
| | | * opus_int32 rate; |
| | | * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); |
| | | * |
| | | * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
| | | * @endcode |
| | | * |
| | | * @see opus_genericctls, opus_encoder |
| | | * @{ |
| | | */ |
| | | |
| | | /** Configures the encoder's computational complexity. |
| | | * The supported range is 0-10 inclusive with 10 representing the highest complexity. |
| | | * @see OPUS_GET_COMPLEXITY |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. |
| | | * |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's complexity configuration. |
| | | * @see OPUS_SET_COMPLEXITY |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, |
| | | * inclusive. |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Configures the bitrate in the encoder. |
| | | * Rates from 500 to 512000 bits per second are meaningful, as well as the |
| | | * special values #OPUS_AUTO and #OPUS_BITRATE_MAX. |
| | | * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much |
| | | * rate as it can, which is useful for controlling the rate by adjusting the |
| | | * output buffer size. |
| | | * @see OPUS_GET_BITRATE |
| | | * @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default |
| | | * is determined based on the number of |
| | | * channels and the input sampling rate. |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's bitrate configuration. |
| | | * @see OPUS_SET_BITRATE |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second. |
| | | * The default is determined based on the |
| | | * number of channels and the input |
| | | * sampling rate. |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Enables or disables variable bitrate (VBR) in the encoder. |
| | | * The configured bitrate may not be met exactly because frames must |
| | | * be an integer number of bytes in length. |
| | | * @see OPUS_GET_VBR |
| | | * @see OPUS_SET_VBR_CONSTRAINT |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can |
| | | * cause noticeable quality degradation.</dd> |
| | | * <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by |
| | | * #OPUS_SET_VBR_CONSTRAINT.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) |
| | | /** Determine if variable bitrate (VBR) is enabled in the encoder. |
| | | * @see OPUS_SET_VBR |
| | | * @see OPUS_GET_VBR_CONSTRAINT |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Hard CBR.</dd> |
| | | * <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via |
| | | * #OPUS_GET_VBR_CONSTRAINT.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Enables or disables constrained VBR in the encoder. |
| | | * This setting is ignored when the encoder is in CBR mode. |
| | | * @warning Only the MDCT mode of Opus currently heeds the constraint. |
| | | * Speech mode ignores it completely, hybrid mode may fail to obey it |
| | | * if the LPC layer uses more bitrate than the constraint would have |
| | | * permitted. |
| | | * @see OPUS_GET_VBR_CONSTRAINT |
| | | * @see OPUS_SET_VBR |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Unconstrained VBR.</dd> |
| | | * <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one |
| | | * frame of buffering delay assuming a transport with a |
| | | * serialization speed of the nominal bitrate.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) |
| | | /** Determine if constrained VBR is enabled in the encoder. |
| | | * @see OPUS_SET_VBR_CONSTRAINT |
| | | * @see OPUS_GET_VBR |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Unconstrained VBR.</dd> |
| | | * <dt>1</dt><dd>Constrained VBR (default).</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Configures mono/stereo forcing in the encoder. |
| | | * This can force the encoder to produce packets encoded as either mono or |
| | | * stereo, regardless of the format of the input audio. This is useful when |
| | | * the caller knows that the input signal is currently a mono source embedded |
| | | * in a stereo stream. |
| | | * @see OPUS_GET_FORCE_CHANNELS |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
| | | * <dt>1</dt> <dd>Forced mono</dd> |
| | | * <dt>2</dt> <dd>Forced stereo</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's forced channel configuration. |
| | | * @see OPUS_SET_FORCE_CHANNELS |
| | | * @param[out] x <tt>opus_int32 *</tt>: |
| | | * <dl> |
| | | * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
| | | * <dt>1</dt> <dd>Forced mono</dd> |
| | | * <dt>2</dt> <dd>Forced stereo</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Configures the maximum bandpass that the encoder will select automatically. |
| | | * Applications should normally use this instead of #OPUS_SET_BANDWIDTH |
| | | * (leaving that set to the default, #OPUS_AUTO). This allows the |
| | | * application to set an upper bound based on the type of input it is |
| | | * providing, but still gives the encoder the freedom to reduce the bandpass |
| | | * when the bitrate becomes too low, for better overall quality. |
| | | * @see OPUS_GET_MAX_BANDWIDTH |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
| | | * <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
| | | * <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
| | | * <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
| | | * <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) |
| | | |
| | | /** Gets the encoder's configured maximum allowed bandpass. |
| | | * @see OPUS_SET_MAX_BANDWIDTH |
| | | * @param[out] x <tt>opus_int32 *</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Sets the encoder's bandpass to a specific value. |
| | | * This prevents the encoder from automatically selecting the bandpass based |
| | | * on the available bitrate. If an application knows the bandpass of the input |
| | | * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH |
| | | * instead, which still gives the encoder the freedom to reduce the bandpass |
| | | * when the bitrate becomes too low, for better overall quality. |
| | | * @see OPUS_GET_BANDWIDTH |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| | | * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) |
| | | |
| | | /** Configures the type of signal being encoded. |
| | | * This is a hint which helps the encoder's mode selection. |
| | | * @see OPUS_GET_SIGNAL |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| | | * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
| | | * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's configured signal type. |
| | | * @see OPUS_SET_SIGNAL |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| | | * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
| | | * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | |
| | | /** Configures the encoder's intended application. |
| | | * The initial value is a mandatory argument to the encoder_create function. |
| | | * @see OPUS_GET_APPLICATION |
| | | * @param[in] x <tt>opus_int32</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>#OPUS_APPLICATION_VOIP</dt> |
| | | * <dd>Process signal for improved speech intelligibility.</dd> |
| | | * <dt>#OPUS_APPLICATION_AUDIO</dt> |
| | | * <dd>Favor faithfulness to the original input.</dd> |
| | | * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
| | | * <dd>Configure the minimum possible coding delay by disabling certain modes |
| | | * of operation.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's configured application. |
| | | * @see OPUS_SET_APPLICATION |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>#OPUS_APPLICATION_VOIP</dt> |
| | | * <dd>Process signal for improved speech intelligibility.</dd> |
| | | * <dt>#OPUS_APPLICATION_AUDIO</dt> |
| | | * <dd>Favor faithfulness to the original input.</dd> |
| | | * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
| | | * <dd>Configure the minimum possible coding delay by disabling certain modes |
| | | * of operation.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Gets the total samples of delay added by the entire codec. |
| | | * This can be queried by the encoder and then the provided number of samples can be |
| | | * skipped on from the start of the decoder's output to provide time aligned input |
| | | * and output. From the perspective of a decoding application the real data begins this many |
| | | * samples late. |
| | | * |
| | | * The decoder contribution to this delay is identical for all decoders, but the |
| | | * encoder portion of the delay may vary from implementation to implementation, |
| | | * version to version, or even depend on the encoder's initial configuration. |
| | | * Applications needing delay compensation should call this CTL rather than |
| | | * hard-coding a value. |
| | | * @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Configures the encoder's use of inband forward error correction (FEC). |
| | | * @note This is only applicable to the LPC layer |
| | | * @see OPUS_GET_INBAND_FEC |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Disable inband FEC (default).</dd> |
| | | * <dt>1</dt><dd>Enable inband FEC.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) |
| | | /** Gets encoder's configured use of inband forward error correction. |
| | | * @see OPUS_SET_INBAND_FEC |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Inband FEC disabled (default).</dd> |
| | | * <dt>1</dt><dd>Inband FEC enabled.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Configures the encoder's expected packet loss percentage. |
| | | * Higher values trigger progressively more loss resistant behavior in the encoder |
| | | * at the expense of quality at a given bitrate in the absence of packet loss, but |
| | | * greater quality under loss. |
| | | * @see OPUS_GET_PACKET_LOSS_PERC |
| | | * @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0). |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's configured packet loss percentage. |
| | | * @see OPUS_SET_PACKET_LOSS_PERC |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage |
| | | * in the range 0-100, inclusive (default: 0). |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Configures the encoder's use of discontinuous transmission (DTX). |
| | | * @note This is only applicable to the LPC layer |
| | | * @see OPUS_GET_DTX |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Disable DTX (default).</dd> |
| | | * <dt>1</dt><dd>Enabled DTX.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) |
| | | /** Gets encoder's configured use of discontinuous transmission. |
| | | * @see OPUS_SET_DTX |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>DTX disabled (default).</dd> |
| | | * <dt>1</dt><dd>DTX enabled.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) |
| | | /** Configures the depth of signal being encoded. |
| | | * |
| | | * This is a hint which helps the encoder identify silence and near-silence. |
| | | * It represents the number of significant bits of linear intensity below |
| | | * which the signal contains ignorable quantization or other noise. |
| | | * |
| | | * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting |
| | | * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate |
| | | * for 16-bit linear pcm input with opus_encode_float(). |
| | | * |
| | | * When using opus_encode() instead of opus_encode_float(), or when libopus |
| | | * is compiled for fixed-point, the encoder uses the minimum of the value |
| | | * set here and the value 16. |
| | | * |
| | | * @see OPUS_GET_LSB_DEPTH |
| | | * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 |
| | | * (default: 24). |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's configured signal depth. |
| | | * @see OPUS_SET_LSB_DEPTH |
| | | * @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and |
| | | * 24 (default: 24). |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Configures the encoder's use of variable duration frames. |
| | | * When variable duration is enabled, the encoder is free to use a shorter frame |
| | | * size than the one requested in the opus_encode*() call. |
| | | * It is then the user's responsibility |
| | | * to verify how much audio was encoded by checking the ToC byte of the encoded |
| | | * packet. The part of the audio that was not encoded needs to be resent to the |
| | | * encoder for the next call. Do not use this option unless you <b>really</b> |
| | | * know what you are doing. |
| | | * @see OPUS_GET_EXPERT_FRAME_DURATION |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
| | | * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's configured use of variable duration frames. |
| | | * @see OPUS_SET_EXPERT_FRAME_DURATION |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
| | | * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
| | | * <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** If set to 1, disables almost all use of prediction, making frames almost |
| | | * completely independent. This reduces quality. |
| | | * @see OPUS_GET_PREDICTION_DISABLED |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Enable prediction (default).</dd> |
| | | * <dt>1</dt><dd>Disable prediction.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) |
| | | /** Gets the encoder's configured prediction status. |
| | | * @see OPUS_SET_PREDICTION_DISABLED |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>0</dt><dd>Prediction enabled (default).</dd> |
| | | * <dt>1</dt><dd>Prediction disabled.</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /**@}*/ |
| | | |
| | | /** @defgroup opus_genericctls Generic CTLs |
| | | * |
| | | * These macros are used with the \c opus_decoder_ctl and |
| | | * \c opus_encoder_ctl calls to generate a particular |
| | | * request. |
| | | * |
| | | * When called on an \c OpusDecoder they apply to that |
| | | * particular decoder instance. When called on an |
| | | * \c OpusEncoder they apply to the corresponding setting |
| | | * on that encoder instance, if present. |
| | | * |
| | | * Some usage examples: |
| | | * |
| | | * @code |
| | | * int ret; |
| | | * opus_int32 pitch; |
| | | * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); |
| | | * if (ret == OPUS_OK) return ret; |
| | | * |
| | | * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
| | | * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); |
| | | * |
| | | * opus_int32 enc_bw, dec_bw; |
| | | * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); |
| | | * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); |
| | | * if (enc_bw != dec_bw) { |
| | | * printf("packet bandwidth mismatch!\n"); |
| | | * } |
| | | * @endcode |
| | | * |
| | | * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls |
| | | * @{ |
| | | */ |
| | | |
| | | /** Resets the codec state to be equivalent to a freshly initialized state. |
| | | * This should be called when switching streams in order to prevent |
| | | * the back to back decoding from giving different results from |
| | | * one at a time decoding. |
| | | * @hideinitializer */ |
| | | #define OPUS_RESET_STATE 4028 |
| | | |
| | | /** Gets the final state of the codec's entropy coder. |
| | | * This is used for testing purposes, |
| | | * The encoder and decoder state should be identical after coding a payload |
| | | * (assuming no data corruption or software bugs) |
| | | * |
| | | * @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state |
| | | * |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) |
| | | |
| | | /** Gets the encoder's configured bandpass or the decoder's last bandpass. |
| | | * @see OPUS_SET_BANDWIDTH |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| | | * <dl> |
| | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| | | * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
| | | * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
| | | * </dl> |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Gets the sampling rate the encoder or decoder was initialized with. |
| | | * This simply returns the <code>Fs</code> value passed to opus_encoder_init() |
| | | * or opus_decoder_init(). |
| | | * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. |
| | | * @hideinitializer |
| | | */ |
| | | #define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /**@}*/ |
| | | |
| | | /** @defgroup opus_decoderctls Decoder related CTLs |
| | | * @see opus_genericctls, opus_encoderctls, opus_decoder |
| | | * @{ |
| | | */ |
| | | |
| | | /** Configures decoder gain adjustment. |
| | | * Scales the decoded output by a factor specified in Q8 dB units. |
| | | * This has a maximum range of -32768 to 32767 inclusive, and returns |
| | | * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. |
| | | * This setting survives decoder reset. |
| | | * |
| | | * gain = pow(10, x/(20.0*256)) |
| | | * |
| | | * @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units. |
| | | * @hideinitializer */ |
| | | #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) |
| | | /** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN |
| | | * |
| | | * @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units. |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Gets the duration (in samples) of the last packet successfully decoded or concealed. |
| | | * @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /** Gets the pitch of the last decoded frame, if available. |
| | | * This can be used for any post-processing algorithm requiring the use of pitch, |
| | | * e.g. time stretching/shortening. If the last frame was not voiced, or if the |
| | | * pitch was not coded in the frame, then zero is returned. |
| | | * |
| | | * This CTL is only implemented for decoder instances. |
| | | * |
| | | * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) |
| | | * |
| | | * @hideinitializer */ |
| | | #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) |
| | | |
| | | /**@}*/ |
| | | |
| | | /** @defgroup opus_libinfo Opus library information functions |
| | | * @{ |
| | | */ |
| | | |
| | | /** Converts an opus error code into a human readable string. |
| | | * |
| | | * @param[in] error <tt>int</tt>: Error number |
| | | * @returns Error string |
| | | */ |
| | | OPUS_EXPORT const char *opus_strerror(int error); |
| | | |
| | | /** Gets the libopus version string. |
| | | * |
| | | * Applications may look for the substring "-fixed" in the version string to |
| | | * determine whether they have a fixed-point or floating-point build at |
| | | * runtime. |
| | | * |
| | | * @returns Version string |
| | | */ |
| | | OPUS_EXPORT const char *opus_get_version_string(void); |
| | | /**@}*/ |
| | | |
| | | #ifdef __cplusplus |
| | | } |
| | | #endif |
| | | |
| | | #endif /* OPUS_DEFINES_H */ |
New file |
| | |
| | | /* Copyright (c) 2011 Xiph.Org Foundation |
| | | Written by Jean-Marc Valin */ |
| | | /* |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions |
| | | are met: |
| | | |
| | | - Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | |
| | | - Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| | | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| | | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | |
| | | /** |
| | | * @file opus_multistream.h |
| | | * @brief Opus reference implementation multistream API |
| | | */ |
| | | |
| | | #ifndef OPUS_MULTISTREAM_H |
| | | #define OPUS_MULTISTREAM_H |
| | | |
| | | #include "opus.h" |
| | | |
| | | #ifdef __cplusplus |
| | | extern "C" { |
| | | #endif |
| | | |
| | | /** @cond OPUS_INTERNAL_DOC */ |
| | | |
| | | /** Macros to trigger compilation errors when the wrong types are provided to a |
| | | * CTL. */ |
| | | /**@{*/ |
| | | #define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr))) |
| | | #define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr))) |
| | | /**@}*/ |
| | | |
| | | /** These are the actual encoder and decoder CTL ID numbers. |
| | | * They should not be used directly by applications. |
| | | * In general, SETs should be even and GETs should be odd.*/ |
| | | /**@{*/ |
| | | #define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 |
| | | #define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 |
| | | /**@}*/ |
| | | |
| | | /** @endcond */ |
| | | |
| | | /** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs |
| | | * |
| | | * These are convenience macros that are specific to the |
| | | * opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl() |
| | | * interface. |
| | | * The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and |
| | | * @ref opus_decoderctls may be applied to a multistream encoder or decoder as |
| | | * well. |
| | | * In addition, you may retrieve the encoder or decoder state for an specific |
| | | * stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or |
| | | * #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually. |
| | | */ |
| | | /**@{*/ |
| | | |
| | | /** Gets the encoder state for an individual stream of a multistream encoder. |
| | | * @param[in] x <tt>opus_int32</tt>: The index of the stream whose encoder you |
| | | * wish to retrieve. |
| | | * This must be non-negative and less than |
| | | * the <code>streams</code> parameter used |
| | | * to initialize the encoder. |
| | | * @param[out] y <tt>OpusEncoder**</tt>: Returns a pointer to the given |
| | | * encoder state. |
| | | * @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
| | | * @hideinitializer |
| | | */ |
| | | #define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) |
| | | |
| | | /** Gets the decoder state for an individual stream of a multistream decoder. |
| | | * @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you |
| | | * wish to retrieve. |
| | | * This must be non-negative and less than |
| | | * the <code>streams</code> parameter used |
| | | * to initialize the decoder. |
| | | * @param[out] y <tt>OpusDecoder**</tt>: Returns a pointer to the given |
| | | * decoder state. |
| | | * @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
| | | * @hideinitializer |
| | | */ |
| | | #define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) |
| | | |
| | | /**@}*/ |
| | | |
| | | /** @defgroup opus_multistream Opus Multistream API |
| | | * @{ |
| | | * |
| | | * The multistream API allows individual Opus streams to be combined into a |
| | | * single packet, enabling support for up to 255 channels. Unlike an |
| | | * elementary Opus stream, the encoder and decoder must negotiate the channel |
| | | * configuration before the decoder can successfully interpret the data in the |
| | | * packets produced by the encoder. Some basic information, such as packet |
| | | * duration, can be computed without any special negotiation. |
| | | * |
| | | * The format for multistream Opus packets is defined in |
| | | * <a href="https://tools.ietf.org/html/rfc7845">RFC 7845</a> |
| | | * and is based on the self-delimited Opus framing described in Appendix B of |
| | | * <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>. |
| | | * Normal Opus packets are just a degenerate case of multistream Opus packets, |
| | | * and can be encoded or decoded with the multistream API by setting |
| | | * <code>streams</code> to <code>1</code> when initializing the encoder or |
| | | * decoder. |
| | | * |
| | | * Multistream Opus streams can contain up to 255 elementary Opus streams. |
| | | * These may be either "uncoupled" or "coupled", indicating that the decoder |
| | | * is configured to decode them to either 1 or 2 channels, respectively. |
| | | * The streams are ordered so that all coupled streams appear at the |
| | | * beginning. |
| | | * |
| | | * A <code>mapping</code> table defines which decoded channel <code>i</code> |
| | | * should be used for each input/output (I/O) channel <code>j</code>. This table is |
| | | * typically provided as an unsigned char array. |
| | | * Let <code>i = mapping[j]</code> be the index for I/O channel <code>j</code>. |
| | | * If <code>i < 2*coupled_streams</code>, then I/O channel <code>j</code> is |
| | | * encoded as the left channel of stream <code>(i/2)</code> if <code>i</code> |
| | | * is even, or as the right channel of stream <code>(i/2)</code> if |
| | | * <code>i</code> is odd. Otherwise, I/O channel <code>j</code> is encoded as |
| | | * mono in stream <code>(i - coupled_streams)</code>, unless it has the special |
| | | * value 255, in which case it is omitted from the encoding entirely (the |
| | | * decoder will reproduce it as silence). Each value <code>i</code> must either |
| | | * be the special value 255 or be less than <code>streams + coupled_streams</code>. |
| | | * |
| | | * The output channels specified by the encoder |
| | | * should use the |
| | | * <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis |
| | | * channel ordering</a>. A decoder may wish to apply an additional permutation |
| | | * to the mapping the encoder used to achieve a different output channel |
| | | * order (e.g. for outputing in WAV order). |
| | | * |
| | | * Each multistream packet contains an Opus packet for each stream, and all of |
| | | * the Opus packets in a single multistream packet must have the same |
| | | * duration. Therefore the duration of a multistream packet can be extracted |
| | | * from the TOC sequence of the first stream, which is located at the |
| | | * beginning of the packet, just like an elementary Opus stream: |
| | | * |
| | | * @code |
| | | * int nb_samples; |
| | | * int nb_frames; |
| | | * nb_frames = opus_packet_get_nb_frames(data, len); |
| | | * if (nb_frames < 1) |
| | | * return nb_frames; |
| | | * nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames; |
| | | * @endcode |
| | | * |
| | | * The general encoding and decoding process proceeds exactly the same as in |
| | | * the normal @ref opus_encoder and @ref opus_decoder APIs. |
| | | * See their documentation for an overview of how to use the corresponding |
| | | * multistream functions. |
| | | */ |
| | | |
| | | /** Opus multistream encoder state. |
| | | * This contains the complete state of a multistream Opus encoder. |
| | | * It is position independent and can be freely copied. |
| | | * @see opus_multistream_encoder_create |
| | | * @see opus_multistream_encoder_init |
| | | */ |
| | | typedef struct OpusMSEncoder OpusMSEncoder; |
| | | |
| | | /** Opus multistream decoder state. |
| | | * This contains the complete state of a multistream Opus decoder. |
| | | * It is position independent and can be freely copied. |
| | | * @see opus_multistream_decoder_create |
| | | * @see opus_multistream_decoder_init |
| | | */ |
| | | typedef struct OpusMSDecoder OpusMSDecoder; |
| | | |
| | | /**\name Multistream encoder functions */ |
| | | /**@{*/ |
| | | |
| | | /** Gets the size of an OpusMSEncoder structure. |
| | | * @param streams <tt>int</tt>: The total number of streams to encode from the |
| | | * input. |
| | | * This must be no more than 255. |
| | | * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
| | | * to encode. |
| | | * This must be no larger than the total |
| | | * number of streams. |
| | | * Additionally, The total number of |
| | | * encoded channels (<code>streams + |
| | | * coupled_streams</code>) must be no |
| | | * more than 255. |
| | | * @returns The size in bytes on success, or a negative error code |
| | | * (see @ref opus_errorcodes) on error. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size( |
| | | int streams, |
| | | int coupled_streams |
| | | ); |
| | | |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size( |
| | | int channels, |
| | | int mapping_family |
| | | ); |
| | | |
| | | |
| | | /** Allocates and initializes a multistream encoder state. |
| | | * Call opus_multistream_encoder_destroy() to release |
| | | * this object when finished. |
| | | * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param channels <tt>int</tt>: Number of channels in the input signal. |
| | | * This must be at most 255. |
| | | * It may be greater than the number of |
| | | * coded channels (<code>streams + |
| | | * coupled_streams</code>). |
| | | * @param streams <tt>int</tt>: The total number of streams to encode from the |
| | | * input. |
| | | * This must be no more than the number of channels. |
| | | * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
| | | * to encode. |
| | | * This must be no larger than the total |
| | | * number of streams. |
| | | * Additionally, The total number of |
| | | * encoded channels (<code>streams + |
| | | * coupled_streams</code>) must be no |
| | | * more than the number of input channels. |
| | | * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
| | | * encoded channels to input channels, as described in |
| | | * @ref opus_multistream. As an extra constraint, the |
| | | * multistream encoder does not allow encoding coupled |
| | | * streams for which one channel is unused since this |
| | | * is never a good idea. |
| | | * @param application <tt>int</tt>: The target encoder application. |
| | | * This must be one of the following: |
| | | * <dl> |
| | | * <dt>#OPUS_APPLICATION_VOIP</dt> |
| | | * <dd>Process signal for improved speech intelligibility.</dd> |
| | | * <dt>#OPUS_APPLICATION_AUDIO</dt> |
| | | * <dd>Favor faithfulness to the original input.</dd> |
| | | * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
| | | * <dd>Configure the minimum possible coding delay by disabling certain modes |
| | | * of operation.</dd> |
| | | * </dl> |
| | | * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
| | | * code (see @ref opus_errorcodes) on |
| | | * failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create( |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int streams, |
| | | int coupled_streams, |
| | | const unsigned char *mapping, |
| | | int application, |
| | | int *error |
| | | ) OPUS_ARG_NONNULL(5); |
| | | |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create( |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int mapping_family, |
| | | int *streams, |
| | | int *coupled_streams, |
| | | unsigned char *mapping, |
| | | int application, |
| | | int *error |
| | | ) OPUS_ARG_NONNULL(5); |
| | | |
| | | /** Initialize a previously allocated multistream encoder state. |
| | | * The memory pointed to by \a st must be at least the size returned by |
| | | * opus_multistream_encoder_get_size(). |
| | | * This is intended for applications which use their own allocator instead of |
| | | * malloc. |
| | | * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
| | | * @see opus_multistream_encoder_create |
| | | * @see opus_multistream_encoder_get_size |
| | | * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
| | | * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param channels <tt>int</tt>: Number of channels in the input signal. |
| | | * This must be at most 255. |
| | | * It may be greater than the number of |
| | | * coded channels (<code>streams + |
| | | * coupled_streams</code>). |
| | | * @param streams <tt>int</tt>: The total number of streams to encode from the |
| | | * input. |
| | | * This must be no more than the number of channels. |
| | | * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
| | | * to encode. |
| | | * This must be no larger than the total |
| | | * number of streams. |
| | | * Additionally, The total number of |
| | | * encoded channels (<code>streams + |
| | | * coupled_streams</code>) must be no |
| | | * more than the number of input channels. |
| | | * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
| | | * encoded channels to input channels, as described in |
| | | * @ref opus_multistream. As an extra constraint, the |
| | | * multistream encoder does not allow encoding coupled |
| | | * streams for which one channel is unused since this |
| | | * is never a good idea. |
| | | * @param application <tt>int</tt>: The target encoder application. |
| | | * This must be one of the following: |
| | | * <dl> |
| | | * <dt>#OPUS_APPLICATION_VOIP</dt> |
| | | * <dd>Process signal for improved speech intelligibility.</dd> |
| | | * <dt>#OPUS_APPLICATION_AUDIO</dt> |
| | | * <dd>Favor faithfulness to the original input.</dd> |
| | | * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
| | | * <dd>Configure the minimum possible coding delay by disabling certain modes |
| | | * of operation.</dd> |
| | | * </dl> |
| | | * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
| | | * on failure. |
| | | */ |
| | | OPUS_EXPORT int opus_multistream_encoder_init( |
| | | OpusMSEncoder *st, |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int streams, |
| | | int coupled_streams, |
| | | const unsigned char *mapping, |
| | | int application |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
| | | |
| | | OPUS_EXPORT int opus_multistream_surround_encoder_init( |
| | | OpusMSEncoder *st, |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int mapping_family, |
| | | int *streams, |
| | | int *coupled_streams, |
| | | unsigned char *mapping, |
| | | int application |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
| | | |
| | | /** Encodes a multistream Opus frame. |
| | | * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
| | | * @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved |
| | | * samples. |
| | | * This must contain |
| | | * <code>frame_size*channels</code> |
| | | * samples. |
| | | * @param frame_size <tt>int</tt>: Number of samples per channel in the input |
| | | * signal. |
| | | * This must be an Opus frame size for the |
| | | * encoder's sampling rate. |
| | | * For example, at 48 kHz the permitted values |
| | | * are 120, 240, 480, 960, 1920, and 2880. |
| | | * Passing in a duration of less than 10 ms |
| | | * (480 samples at 48 kHz) will prevent the |
| | | * encoder from using the LPC or hybrid modes. |
| | | * @param[out] data <tt>unsigned char*</tt>: Output payload. |
| | | * This must contain storage for at |
| | | * least \a max_data_bytes. |
| | | * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
| | | * memory for the output |
| | | * payload. This may be |
| | | * used to impose an upper limit on |
| | | * the instant bitrate, but should |
| | | * not be used as the only bitrate |
| | | * control. Use #OPUS_SET_BITRATE to |
| | | * control the bitrate. |
| | | * @returns The length of the encoded packet (in bytes) on success or a |
| | | * negative error code (see @ref opus_errorcodes) on failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( |
| | | OpusMSEncoder *st, |
| | | const opus_int16 *pcm, |
| | | int frame_size, |
| | | unsigned char *data, |
| | | opus_int32 max_data_bytes |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Encodes a multistream Opus frame from floating point input. |
| | | * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
| | | * @param[in] pcm <tt>const float*</tt>: The input signal as interleaved |
| | | * samples with a normal range of |
| | | * +/-1.0. |
| | | * Samples with a range beyond +/-1.0 |
| | | * are supported but will be clipped by |
| | | * decoders using the integer API and |
| | | * should only be used if it is known |
| | | * that the far end supports extended |
| | | * dynamic range. |
| | | * This must contain |
| | | * <code>frame_size*channels</code> |
| | | * samples. |
| | | * @param frame_size <tt>int</tt>: Number of samples per channel in the input |
| | | * signal. |
| | | * This must be an Opus frame size for the |
| | | * encoder's sampling rate. |
| | | * For example, at 48 kHz the permitted values |
| | | * are 120, 240, 480, 960, 1920, and 2880. |
| | | * Passing in a duration of less than 10 ms |
| | | * (480 samples at 48 kHz) will prevent the |
| | | * encoder from using the LPC or hybrid modes. |
| | | * @param[out] data <tt>unsigned char*</tt>: Output payload. |
| | | * This must contain storage for at |
| | | * least \a max_data_bytes. |
| | | * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
| | | * memory for the output |
| | | * payload. This may be |
| | | * used to impose an upper limit on |
| | | * the instant bitrate, but should |
| | | * not be used as the only bitrate |
| | | * control. Use #OPUS_SET_BITRATE to |
| | | * control the bitrate. |
| | | * @returns The length of the encoded packet (in bytes) on success or a |
| | | * negative error code (see @ref opus_errorcodes) on failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float( |
| | | OpusMSEncoder *st, |
| | | const float *pcm, |
| | | int frame_size, |
| | | unsigned char *data, |
| | | opus_int32 max_data_bytes |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Frees an <code>OpusMSEncoder</code> allocated by |
| | | * opus_multistream_encoder_create(). |
| | | * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to be freed. |
| | | */ |
| | | OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); |
| | | |
| | | /** Perform a CTL function on a multistream Opus encoder. |
| | | * |
| | | * Generally the request and subsequent arguments are generated by a |
| | | * convenience macro. |
| | | * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
| | | * @param request This and all remaining parameters should be replaced by one |
| | | * of the convenience macros in @ref opus_genericctls, |
| | | * @ref opus_encoderctls, or @ref opus_multistream_ctls. |
| | | * @see opus_genericctls |
| | | * @see opus_encoderctls |
| | | * @see opus_multistream_ctls |
| | | */ |
| | | OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
| | | |
| | | /**@}*/ |
| | | |
| | | /**\name Multistream decoder functions */ |
| | | /**@{*/ |
| | | |
| | | /** Gets the size of an <code>OpusMSDecoder</code> structure. |
| | | * @param streams <tt>int</tt>: The total number of streams coded in the |
| | | * input. |
| | | * This must be no more than 255. |
| | | * @param coupled_streams <tt>int</tt>: Number streams to decode as coupled |
| | | * (2 channel) streams. |
| | | * This must be no larger than the total |
| | | * number of streams. |
| | | * Additionally, The total number of |
| | | * coded channels (<code>streams + |
| | | * coupled_streams</code>) must be no |
| | | * more than 255. |
| | | * @returns The size in bytes on success, or a negative error code |
| | | * (see @ref opus_errorcodes) on error. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size( |
| | | int streams, |
| | | int coupled_streams |
| | | ); |
| | | |
| | | /** Allocates and initializes a multistream decoder state. |
| | | * Call opus_multistream_decoder_destroy() to release |
| | | * this object when finished. |
| | | * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param channels <tt>int</tt>: Number of channels to output. |
| | | * This must be at most 255. |
| | | * It may be different from the number of coded |
| | | * channels (<code>streams + |
| | | * coupled_streams</code>). |
| | | * @param streams <tt>int</tt>: The total number of streams coded in the |
| | | * input. |
| | | * This must be no more than 255. |
| | | * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
| | | * (2 channel) streams. |
| | | * This must be no larger than the total |
| | | * number of streams. |
| | | * Additionally, The total number of |
| | | * coded channels (<code>streams + |
| | | * coupled_streams</code>) must be no |
| | | * more than 255. |
| | | * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
| | | * coded channels to output channels, as described in |
| | | * @ref opus_multistream. |
| | | * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
| | | * code (see @ref opus_errorcodes) on |
| | | * failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create( |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int streams, |
| | | int coupled_streams, |
| | | const unsigned char *mapping, |
| | | int *error |
| | | ) OPUS_ARG_NONNULL(5); |
| | | |
| | | /** Intialize a previously allocated decoder state object. |
| | | * The memory pointed to by \a st must be at least the size returned by |
| | | * opus_multistream_encoder_get_size(). |
| | | * This is intended for applications which use their own allocator instead of |
| | | * malloc. |
| | | * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
| | | * @see opus_multistream_decoder_create |
| | | * @see opus_multistream_deocder_get_size |
| | | * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
| | | * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
| | | * This must be one of 8000, 12000, 16000, |
| | | * 24000, or 48000. |
| | | * @param channels <tt>int</tt>: Number of channels to output. |
| | | * This must be at most 255. |
| | | * It may be different from the number of coded |
| | | * channels (<code>streams + |
| | | * coupled_streams</code>). |
| | | * @param streams <tt>int</tt>: The total number of streams coded in the |
| | | * input. |
| | | * This must be no more than 255. |
| | | * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
| | | * (2 channel) streams. |
| | | * This must be no larger than the total |
| | | * number of streams. |
| | | * Additionally, The total number of |
| | | * coded channels (<code>streams + |
| | | * coupled_streams</code>) must be no |
| | | * more than 255. |
| | | * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
| | | * coded channels to output channels, as described in |
| | | * @ref opus_multistream. |
| | | * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
| | | * on failure. |
| | | */ |
| | | OPUS_EXPORT int opus_multistream_decoder_init( |
| | | OpusMSDecoder *st, |
| | | opus_int32 Fs, |
| | | int channels, |
| | | int streams, |
| | | int coupled_streams, |
| | | const unsigned char *mapping |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
| | | |
| | | /** Decode a multistream Opus packet. |
| | | * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
| | | * @param[in] data <tt>const unsigned char*</tt>: Input payload. |
| | | * Use a <code>NULL</code> |
| | | * pointer to indicate packet |
| | | * loss. |
| | | * @param len <tt>opus_int32</tt>: Number of bytes in payload. |
| | | * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
| | | * samples. |
| | | * This must contain room for |
| | | * <code>frame_size*channels</code> |
| | | * samples. |
| | | * @param frame_size <tt>int</tt>: The number of samples per channel of |
| | | * available space in \a pcm. |
| | | * If this is less than the maximum packet duration |
| | | * (120 ms; 5760 for 48kHz), this function will not be capable |
| | | * of decoding some packets. In the case of PLC (data==NULL) |
| | | * or FEC (decode_fec=1), then frame_size needs to be exactly |
| | | * the duration of audio that is missing, otherwise the |
| | | * decoder will not be in the optimal state to decode the |
| | | * next incoming packet. For the PLC and FEC cases, frame_size |
| | | * <b>must</b> be a multiple of 2.5 ms. |
| | | * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
| | | * forward error correction data be decoded. |
| | | * If no such data is available, the frame is |
| | | * decoded as if it were lost. |
| | | * @returns Number of samples decoded on success or a negative error code |
| | | * (see @ref opus_errorcodes) on failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode( |
| | | OpusMSDecoder *st, |
| | | const unsigned char *data, |
| | | opus_int32 len, |
| | | opus_int16 *pcm, |
| | | int frame_size, |
| | | int decode_fec |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Decode a multistream Opus packet with floating point output. |
| | | * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
| | | * @param[in] data <tt>const unsigned char*</tt>: Input payload. |
| | | * Use a <code>NULL</code> |
| | | * pointer to indicate packet |
| | | * loss. |
| | | * @param len <tt>opus_int32</tt>: Number of bytes in payload. |
| | | * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
| | | * samples. |
| | | * This must contain room for |
| | | * <code>frame_size*channels</code> |
| | | * samples. |
| | | * @param frame_size <tt>int</tt>: The number of samples per channel of |
| | | * available space in \a pcm. |
| | | * If this is less than the maximum packet duration |
| | | * (120 ms; 5760 for 48kHz), this function will not be capable |
| | | * of decoding some packets. In the case of PLC (data==NULL) |
| | | * or FEC (decode_fec=1), then frame_size needs to be exactly |
| | | * the duration of audio that is missing, otherwise the |
| | | * decoder will not be in the optimal state to decode the |
| | | * next incoming packet. For the PLC and FEC cases, frame_size |
| | | * <b>must</b> be a multiple of 2.5 ms. |
| | | * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
| | | * forward error correction data be decoded. |
| | | * If no such data is available, the frame is |
| | | * decoded as if it were lost. |
| | | * @returns Number of samples decoded on success or a negative error code |
| | | * (see @ref opus_errorcodes) on failure. |
| | | */ |
| | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float( |
| | | OpusMSDecoder *st, |
| | | const unsigned char *data, |
| | | opus_int32 len, |
| | | float *pcm, |
| | | int frame_size, |
| | | int decode_fec |
| | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
| | | |
| | | /** Perform a CTL function on a multistream Opus decoder. |
| | | * |
| | | * Generally the request and subsequent arguments are generated by a |
| | | * convenience macro. |
| | | * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
| | | * @param request This and all remaining parameters should be replaced by one |
| | | * of the convenience macros in @ref opus_genericctls, |
| | | * @ref opus_decoderctls, or @ref opus_multistream_ctls. |
| | | * @see opus_genericctls |
| | | * @see opus_decoderctls |
| | | * @see opus_multistream_ctls |
| | | */ |
| | | OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
| | | |
| | | /** Frees an <code>OpusMSDecoder</code> allocated by |
| | | * opus_multistream_decoder_create(). |
| | | * @param st <tt>OpusMSDecoder</tt>: Multistream decoder state to be freed. |
| | | */ |
| | | OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); |
| | | |
| | | /**@}*/ |
| | | |
| | | /**@}*/ |
| | | |
| | | #ifdef __cplusplus |
| | | } |
| | | #endif |
| | | |
| | | #endif /* OPUS_MULTISTREAM_H */ |
New file |
| | |
| | | /* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ |
| | | /* Modified by Jean-Marc Valin */ |
| | | /* |
| | | Redistribution and use in source and binary forms, with or without |
| | | modification, are permitted provided that the following conditions |
| | | are met: |
| | | |
| | | - Redistributions of source code must retain the above copyright |
| | | notice, this list of conditions and the following disclaimer. |
| | | |
| | | - Redistributions in binary form must reproduce the above copyright |
| | | notice, this list of conditions and the following disclaimer in the |
| | | documentation and/or other materials provided with the distribution. |
| | | |
| | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| | | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| | | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | /* opus_types.h based on ogg_types.h from libogg */ |
| | | |
| | | /** |
| | | @file opus_types.h |
| | | @brief Opus reference implementation types |
| | | */ |
| | | #ifndef OPUS_TYPES_H |
| | | #define OPUS_TYPES_H |
| | | |
| | | /* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ |
| | | #if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) |
| | | #include <stdint.h> |
| | | |
| | | typedef int16_t opus_int16; |
| | | typedef uint16_t opus_uint16; |
| | | typedef int32_t opus_int32; |
| | | typedef uint32_t opus_uint32; |
| | | #elif defined(_WIN32) |
| | | |
| | | # if defined(__CYGWIN__) |
| | | # include <_G_config.h> |
| | | typedef _G_int32_t opus_int32; |
| | | typedef _G_uint32_t opus_uint32; |
| | | typedef _G_int16 opus_int16; |
| | | typedef _G_uint16 opus_uint16; |
| | | # elif defined(__MINGW32__) |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | typedef int opus_int32; |
| | | typedef unsigned int opus_uint32; |
| | | # elif defined(__MWERKS__) |
| | | typedef int opus_int32; |
| | | typedef unsigned int opus_uint32; |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | # else |
| | | /* MSVC/Borland */ |
| | | typedef __int32 opus_int32; |
| | | typedef unsigned __int32 opus_uint32; |
| | | typedef __int16 opus_int16; |
| | | typedef unsigned __int16 opus_uint16; |
| | | # endif |
| | | |
| | | #elif defined(__MACOS__) |
| | | |
| | | # include <sys/types.h> |
| | | typedef SInt16 opus_int16; |
| | | typedef UInt16 opus_uint16; |
| | | typedef SInt32 opus_int32; |
| | | typedef UInt32 opus_uint32; |
| | | |
| | | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ |
| | | |
| | | # include <sys/types.h> |
| | | typedef int16_t opus_int16; |
| | | typedef u_int16_t opus_uint16; |
| | | typedef int32_t opus_int32; |
| | | typedef u_int32_t opus_uint32; |
| | | |
| | | #elif defined(__BEOS__) |
| | | |
| | | /* Be */ |
| | | # include <inttypes.h> |
| | | typedef int16 opus_int16; |
| | | typedef u_int16 opus_uint16; |
| | | typedef int32_t opus_int32; |
| | | typedef u_int32_t opus_uint32; |
| | | |
| | | #elif defined (__EMX__) |
| | | |
| | | /* OS/2 GCC */ |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | typedef int opus_int32; |
| | | typedef unsigned int opus_uint32; |
| | | |
| | | #elif defined (DJGPP) |
| | | |
| | | /* DJGPP */ |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | typedef int opus_int32; |
| | | typedef unsigned int opus_uint32; |
| | | |
| | | #elif defined(R5900) |
| | | |
| | | /* PS2 EE */ |
| | | typedef int opus_int32; |
| | | typedef unsigned opus_uint32; |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | |
| | | #elif defined(__SYMBIAN32__) |
| | | |
| | | /* Symbian GCC */ |
| | | typedef signed short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | typedef signed int opus_int32; |
| | | typedef unsigned int opus_uint32; |
| | | |
| | | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) |
| | | |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | typedef long opus_int32; |
| | | typedef unsigned long opus_uint32; |
| | | |
| | | #elif defined(CONFIG_TI_C6X) |
| | | |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | typedef int opus_int32; |
| | | typedef unsigned int opus_uint32; |
| | | |
| | | #else |
| | | |
| | | /* Give up, take a reasonable guess */ |
| | | typedef short opus_int16; |
| | | typedef unsigned short opus_uint16; |
| | | typedef int opus_int32; |
| | | typedef unsigned int opus_uint32; |
| | | |
| | | #endif |
| | | |
| | | #define opus_int int /* used for counters etc; at least 16 bits */ |
| | | #define opus_int64 long long |
| | | #define opus_int8 signed char |
| | | |
| | | #define opus_uint unsigned int /* used for counters etc; at least 16 bits */ |
| | | #define opus_uint64 unsigned long long |
| | | #define opus_uint8 unsigned char |
| | | |
| | | #endif /* OPUS_TYPES_H */ |
New file |
| | |
| | | // |
| | | // Tracking.h |
| | | // ReYun_Tracking |
| | | // |
| | | // Created by jesse on 2018/1/19. |
| | | // Copyright © 2018年 yun. All rights reserved. |
| | | // |
| | | #define REYUN_TRACKING_VERSION @"1.3.0" |
| | | #import <Foundation/Foundation.h> |
| | | NS_ASSUME_NONNULL_BEGIN |
| | | @interface Tracking : NSObject |
| | | //开启打印日志 正式上线包请关掉 |
| | | +(void) setPrintLog :(BOOL)print; |
| | | // 开启数据统计 |
| | | + (void)initWithAppKey:(NSString *)appKey withChannelId:(NSString *)channelId; |
| | | //注册成功后调用 |
| | | + (void)setRegisterWithAccountID:(NSString *)account; |
| | | //登陆成功后调用 |
| | | + (void)setLoginWithAccountID:(NSString *)account; |
| | | //生成订单 |
| | | +(void)setDD:(NSString *)ryTID hbType:(NSString*)hbType hbAmount:(float)hbAmount; |
| | | //开始付费时 调用(人民币单位是元) |
| | | +(void)setRyzfStart:(NSString *)ryTID ryzfType:(NSString*)ryzfType hbType:(NSString*)hbType hbAmount:(float)hbAmount; |
| | | // 支付完成,付费分析,记录玩家充值的金额(人民币单位是元) |
| | | +(void)setRyzf:(NSString *)ryTID ryzfType:(NSString*)ryzfType hbType:(NSString*)hbType hbAmount:(float)hbAmount; |
| | | //自定义事件 |
| | | +(void)setEvent:(NSString *)eventName; |
| | | //获取设备信息 |
| | | +(NSString*)getDeviceId; |
| | | @end |
| | | NS_ASSUME_NONNULL_END |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 14af147b00f5448428067bc0bd1a20a7 |
| | | folderAsset: yes |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | // |
| | | // TTABTestConfFetcher.h |
| | | // TTTracker |
| | | // |
| | | // Created by fengyadong on 2017/6/18. |
| | | // Copyright © 2017年 fengyadong. All rights reserved. |
| | | // |
| | | |
| | | //#if (defined TOBSDK) || (defined VALIDATION) |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | |
| | | typedef void(^TTABTestFinishBlock)(NSDictionary *allConfigs); |
| | | |
| | | @interface TTABTestConfFetcher : NSObject |
| | | |
| | | @property (atomic, copy, readonly) NSDictionary *allConfigs;/*当前最新的全量的配置信息*/ |
| | | @property (atomic, copy, readonly) NSString *abVersions;/*该用户命中的所有客户端AB实验标示*/ |
| | | @property (atomic, copy, readonly) NSString *abServerVersions;/*该用户命中的所有服务端AB实验标示*/ |
| | | |
| | | /** |
| | | 单例方法 |
| | | |
| | | @return TTABTestConfFetcher单例 |
| | | */ |
| | | + (instancetype)sharedInstance; |
| | | |
| | | /** |
| | | 开始异步拉取ABTest配置信息 |
| | | |
| | | @param finishBlock 拉取结束的回调 |
| | | */ |
| | | - (void)startFetchABTestConf:(TTABTestFinishBlock)finishBlock; |
| | | |
| | | /** |
| | | 获取指定ABTest实验的返回值 |
| | | |
| | | @param key ABTest实验的名字 |
| | | @param defaultValue 默认值,如果下发Conf中没有找到对应的key |
| | | @return ABTest的返回值 |
| | | */ |
| | | - (id)getConfig:(NSString *)key defaultValue:(id)defaultValue; |
| | | |
| | | /** |
| | | 设置服务端实验的AB实验参数 |
| | | |
| | | @param versions 服务端实验的AB实验参数 |
| | | */ |
| | | - (void)setServerVersions:(NSString *)versions; |
| | | |
| | | @end |
| | | |
| | | //#endif |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 5d096069665e1462aba68355e7533a19 |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | // |
| | | // TTInstallBaseMacro.h |
| | | // Article |
| | | // |
| | | // Created by panxiang on 15/11/5. |
| | | // |
| | | // |
| | | |
| | | #ifndef TTInstallBaseMacro_h |
| | | #define TTInstallBaseMacro_h |
| | | |
| | | #define WeakSelf __weak typeof(self) wself = self |
| | | #define StrongSelf __strong typeof(wself) self = wself |
| | | |
| | | #ifdef DEBUG |
| | | |
| | | #define TTInstallLOGD( s, ... ) NSLog(@"Debug %s: %@", __FUNCTION__, [NSString stringWithFormat:(s), ##__VA_ARGS__]) |
| | | |
| | | #define TTInstallLOGT( s, ... ) NSLog(@"Trace %s: %@", __FUNCTION__, [NSString stringWithFormat:(s), ##__VA_ARGS__]) |
| | | |
| | | #define TTInstallTICK NSDate *startTime = [NSDate date] |
| | | #define TTInstallTOCK LOGD(@"took time: %f seconds.", -[startTime timeIntervalSinceNow]) |
| | | |
| | | #else |
| | | |
| | | #define TTInstallLOGD( s, ... ) |
| | | #define TTInstallLOGT( s, ... ) |
| | | #define TTInstallTICK |
| | | #define TTInstallTOCK |
| | | |
| | | #endif |
| | | |
| | | |
| | | #ifndef TTInstallIsEmptyString |
| | | #define TTInstallIsEmptyString(str) (!str || ![str isKindOfClass:[NSString class]] || str.length == 0) |
| | | #endif |
| | | |
| | | #ifndef TTInstallIsEmptyArray |
| | | #define TTInstallIsEmptyArray(array) (!array || ![array isKindOfClass:[NSArray class]] || array.count == 0) |
| | | #endif |
| | | |
| | | #ifndef TTInstallIsEmptyDictionary |
| | | #define TTInstallIsEmptyDictionary(dict) (!dict || ![dict isKindOfClass:[NSDictionary class]] || ((NSDictionary *)dict).count == 0) |
| | | #endif |
| | | |
| | | #endif /* TTInstallBaseMacro_h */ |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: e093e6de16cd449b4b0457b63176f5df |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | // |
| | | // TTInstallIDManager.h |
| | | // Article |
| | | // |
| | | // Created by fengyadong on 17-3-14. |
| | | // |
| | | // |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | |
| | | /** 设备注册完成回调 */ |
| | | typedef void(^TTInstallDidRegisterBlock)(NSString *deviceID, NSString *installID, NSString *ssID); |
| | | |
| | | /** 自定义Header中的扩展字段,在header中独立的custom结构中 */ |
| | | typedef NSDictionary<NSString*, id> *(^TTCustomHeaderBlock)(void); |
| | | |
| | | @interface TTInstallIDManager : NSObject |
| | | |
| | | @property (nonatomic, copy, readonly) NSString *appID;/** app的唯一标示,由头条数据仓库团队统一分配 */ |
| | | @property (nonatomic, copy, readonly) NSString *channel;/** 渠道名称 */ |
| | | @property (nonatomic, copy, readonly) NSString *deviceID;/** 设备id */ |
| | | @property (nonatomic, copy, readonly) NSString *installID;/** 安装id */ |
| | | @property (nonatomic, copy, readonly) NSString *appName; |
| | | @property (nonatomic, copy, readonly) NSString *ssID;/** 用户id,串联匿名和登录用户 */ |
| | | @property (nonatomic, copy, readonly) NSString *userUniqueID;/** 正在注册ssid的user_unique_id */ |
| | | |
| | | @property (nonatomic, copy) TTCustomHeaderBlock customHeaderBlock;/** 使用方自定义Header参数 */ |
| | | |
| | | + (instancetype)sharedInstance; |
| | | |
| | | |
| | | /** |
| | | 是否开启激活设备开关 |
| | | |
| | | @param enable YES:开启 NO:关闭 default:YES |
| | | |
| | | warning ⚠️:如果要关掉激活设备开关此方法必须在 -startWithAppID:channel:appName:finishBlock前调用 |
| | | */ |
| | | + (void)setActivateDeviceEnable:(BOOL)enable; |
| | | |
| | | //=============================================初始化方法================================================== |
| | | /** |
| | | 开始调用服务端设备注册接口 |
| | | |
| | | @param appID 当前app的唯一标示,由头条数据仓库团队统一分配 |
| | | @param channel 渠道名称,建议正式版App Store 内测版local_test 灰度版用发布的渠道名,如pp |
| | | @param appName 由数据方指定的APP name |
| | | @param didRegisterBlock 设备注册接口完成回调,最多回调一次,没有超时时间。如果已经注册则立马回调,如果还没有则等接口请求解析完成回调。对device_id有依赖的接口可以在这里发送 |
| | | */ |
| | | - (void)startWithAppID:(NSString *)appID |
| | | channel:(NSString *)channel |
| | | appName:(NSString *)appName |
| | | finishBlock:(TTInstallDidRegisterBlock)didRegisterBlock; |
| | | |
| | | //===========================================注册完成回调方法================================================ |
| | | /** |
| | | 设备注册完成的回调 |
| | | |
| | | @param didRegisterBlock 设备注册接口完成回调,最多回调一次,没有超时时间。如果已经注册则立马回调,如果还没有则等接口请求解析完成回调。对device_id有依赖的接口可以在这里发送 |
| | | */ |
| | | - (void)setDidRegisterBlock:(TTInstallDidRegisterBlock)didRegisterBlock; |
| | | |
| | | //=========================================== Debug模式配置 ================================================ |
| | | /** |
| | | 设置当前环境是否为内测版本 |
| | | |
| | | @param isInHouseVersion 是否为内测版本 |
| | | */ |
| | | - (void)setIsInHouseVersion:(BOOL)isInHouseVersion; |
| | | |
| | | //=========================================== User-Profile ================================================ |
| | | |
| | | /** |
| | | 用户登录状态发生变更的时候需要调用此接口,传入当前的用户的user_unique_id |
| | | |
| | | @param uniqueID 用户当前的user_unique_id |
| | | */ |
| | | - (void)setCurrentUserUniqueID:(NSString *)uniqueID; |
| | | |
| | | /** |
| | | 用户登录状态发生变更的时候需要调用此接口,传入当前的用户的user_unique_id,并且关心SSID重新获取的时机 |
| | | |
| | | @param uniqueID 用户当前的user_unique_id |
| | | @param didRetriveBlock 重新获取SSID的回调 |
| | | */ |
| | | - (void)setCurrentUserUniqueID:(NSString *)uniqueID |
| | | didRetriveSSIDBlock:(TTInstallDidRegisterBlock)didRetriveBlock; |
| | | |
| | | @end |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 4c44bda463bd64728b0ed78c6704c621 |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | // |
| | | // TTTracker+Game.h |
| | | // Pods |
| | | // |
| | | // Created by fengyadong on 2017/9/13. |
| | | // |
| | | // |
| | | //#if (defined GAMESDK) || (defined VALIDATION) |
| | | |
| | | #import <TTTracker/TTTracker.h> |
| | | |
| | | @interface TTTracker (Game) |
| | | |
| | | /** |
| | | 用户注册流程完成时调用此接口 |
| | | |
| | | @param method 表示注册方式,业务方可以传任意可标识注册方式的值,如注册方式为手机号:method = @"phone" 微信注册:method = @“WeChat”等。 |
| | | 这个参数作用:方便业务方在数据平台以method为key查询数据 |
| | | @param isSuccess 是否注册成功 |
| | | */ |
| | | + (void)registerEventByMethod:(NSString *)method isSuccess:(BOOL)isSuccess; |
| | | |
| | | /** |
| | | 用户登录完成时调用此接口 |
| | | |
| | | @param method 表示登录的方式,如游戏账号、手机号等 |
| | | @param isSuccess 是否登录成功 |
| | | */ |
| | | + (void)loginEventByMethod:(NSString *)method isSuccess:(BOOL)isSuccess; |
| | | |
| | | /** |
| | | 绑定社交账户时调用此接口 |
| | | |
| | | @param method 表示登录的方式,如游戏账号、手机号等 |
| | | @param isSuccess 是否注册成功 |
| | | */ |
| | | |
| | | /** |
| | | 绑定社交账户时调用此接口 |
| | | |
| | | @param type 社交账号类型 如如微信、微博等 |
| | | @param isSuccess 是否绑定成功 |
| | | */ |
| | | + (void)accessAccountEventByType:(NSString *)type isSuccess:(BOOL)isSuccess; |
| | | |
| | | /** |
| | | 完成节点(如教学/任务/副本)时调用此接口 |
| | | |
| | | @param questID 教学/任务/副本等关卡标识符 |
| | | @param type 节点类型 |
| | | @param name 教学/任务/副本等关卡名称 |
| | | @param number 第几个任务节点 |
| | | @param desc 节点描述 |
| | | @param isSuccess 节点是否完成 |
| | | */ |
| | | + (void)questEventWithQuestID:(NSString *)questID |
| | | questType:(NSString *)type |
| | | questName:(NSString *)name |
| | | questNumer:(NSUInteger)number |
| | | description:(NSString *)desc |
| | | isSuccess:(BOOL)isSuccess; |
| | | |
| | | /** |
| | | 用户升级后调用此接口 |
| | | |
| | | @param level 当前用户等级 |
| | | */ |
| | | + (void)updateLevelEventWithLevel:(NSUInteger)level; |
| | | |
| | | /** |
| | | 查看内容/商品详情时调用此接口 |
| | | |
| | | @param type 内容类型如“配备”、“皮肤” |
| | | @param name 商品或内容名称 |
| | | @param contentID 商品或内容标识符 |
| | | */ |
| | | + (void)viewContentEventWithContentType:(NSString *)type |
| | | contentName:(NSString *)name |
| | | contentID:(NSString *)contentID; |
| | | |
| | | /** |
| | | 加入购买/购物车时调用此接口 |
| | | |
| | | @param type 内容类型如“配备”、“皮肤” |
| | | @param name 商品或内容名称 |
| | | @param contentID 商品或内容标识符 |
| | | @param number 商品数量 |
| | | @param isSuccess 加入购买/购物车是否成功 |
| | | */ |
| | | + (void)addCartEventWithContentType:(NSString *)type |
| | | contentName:(NSString *)name |
| | | contentID:(NSString *)contentID |
| | | contentNumber:(NSUInteger)number |
| | | isSuccess:(BOOL)isSuccess; |
| | | |
| | | /** |
| | | 提交购买/下单时调用此接口 |
| | | |
| | | @param type 内容类型如“配备”、“皮肤” |
| | | @param name 商品或内容名称 |
| | | @param contentID 商品或内容标识符 |
| | | @param number 商品数量 |
| | | @param isVirtualCurrency 是否使用的是虚拟货币 |
| | | @param virtualCurrency 虚拟货币类型,如"元宝"、“金币”等 |
| | | @param currency 真实货币类型,ISO 4217代码,如:“USD” |
| | | @param isSuccess 提交购买/下单是否成功 |
| | | */ |
| | | + (void)checkoutEventWithContentType:(NSString *)type |
| | | contentName:(NSString *)name |
| | | contentID:(NSString *)contentID |
| | | contentNumber:(NSUInteger)number |
| | | isVirtualCurrency:(BOOL)isVirtualCurrency |
| | | virtualCurrency:(NSString *)virtualCurrency |
| | | currency:(NSString *)currency |
| | | isSuccess:(BOOL)isSuccess; |
| | | |
| | | /** |
| | | 支付时调用此接口 |
| | | |
| | | @param type 内容类型如“配备”、“皮肤” |
| | | @param name 商品或内容名称 |
| | | @param contentID 商品或内容标识符 |
| | | @param number 商品数量 |
| | | @param channel 支付渠道名,如支付宝、微信等 |
| | | @param currency 真实货币类型,ISO 4217代码,如:“USD” |
| | | @param amount 本次支付的真实货币的金额 |
| | | @param isSuccess 支付是否成功 |
| | | */ |
| | | + (void)purchaseEventWithContentType:(NSString *)type |
| | | contentName:(NSString *)name |
| | | contentID:(NSString *)contentID |
| | | contentNumber:(NSUInteger)number |
| | | paymentChannel:(NSString *)channel |
| | | currency:(NSString *)currency |
| | | currency_amount:(unsigned long long)amount |
| | | isSuccess:(BOOL)isSuccess; |
| | | |
| | | /** |
| | | 添加支付渠道时调用此接口 |
| | | |
| | | @param channel 支付渠道名,如支付宝、微信等 |
| | | @param isSuccess 添加支付渠道是否成功 |
| | | */ |
| | | + (void)accessPaymentChannelEventByChannel:(NSString *)channel isSuccess:(BOOL)isSuccess; |
| | | |
| | | @end |
| | | |
| | | //#endif |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: e16e24f1452664db7899861623b32bd8 |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | // |
| | | // TTTracker.h |
| | | // TTTracker |
| | | // |
| | | // Created by fengyadong on 2017-3-14. |
| | | // Copyright (c) 2017 toutiao. All rights reserved. |
| | | // |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import "TTInstallIDManager.h" |
| | | #ifndef TOBSDK |
| | | #import "TTTrackerHeader.h" |
| | | #import "TTInstallBaseMacro.h" |
| | | #endif |
| | | |
| | | //+----------------+----------+----------+---------+--------------------------+ |
| | | //| Key | Type | Required | Default | Meaning | |
| | | //+----------------+----------+----------+---------+--------------------------+ |
| | | //| user_id | String | NO | NULL | login user_id | |
| | | //| need_encrypt | BOOL | NO | YES | whether encrypt | |
| | | //| user_unique_id | String | NO | NULL | unique_id for login user | |
| | | //+----------------+----------+----------+---------+--------------------------+ |
| | | typedef NSDictionary *_Nullable(^TTTrackerConfigParamsBlock)(void); |
| | | /** 捕获一个即将被缓存的log */ |
| | | typedef void(^TTTrackerLogHookBlock)(NSDictionary * _Nonnull hookedLog); |
| | | |
| | | @interface TTTracker : NSObject |
| | | |
| | | @property (nonatomic, copy, readonly) NSString * _Nonnull appID;/** 应用唯一标示 */ |
| | | @property (nonatomic, copy, readonly) NSString * _Nonnull channel;/** 应用发布的渠道名 */ |
| | | |
| | | //可选配置 |
| | | @property (nonatomic, copy) TTTrackerConfigParamsBlock _Nullable configParamsBlock;/** 外部使用方配置是否加密等参数 */ |
| | | @property (nonatomic, copy) TTCustomHeaderBlock _Nullable customHeaderBlock;/** 使用方自定义Header参数 */ |
| | | @property (nonatomic, copy, readonly) NSDictionary<NSString*, id> *_Nullable configParams;/** 配置信息参数 */ |
| | | @property (atomic, copy, readonly) NSDictionary<NSString*, TTTrackerLogHookBlock> *_Nullable logHookDict; |
| | | |
| | | //是否开启session YES开启NO关闭 default= YES ⚠️必须在+startWithAppID:channel:appName前设置才有效 |
| | | @property (nonatomic, assign) BOOL sessionEnalbe; |
| | | |
| | | //==================================单例方法====================================== |
| | | + (instancetype _Nonnull)sharedInstance; |
| | | |
| | | //==================================初始化方法==================================== |
| | | /** |
| | | 启动tracker服务 |
| | | |
| | | @param appID 应用标示,由头条数据仓库组统一分配 |
| | | @param appName 应用名,需向头条申请 |
| | | @param channel 渠道名称,建议正式版App Store 内测版local_test 灰度版用发布的渠道名,如pp |
| | | */ |
| | | + (void)startWithAppID:(NSString *_Nonnull)appID channel:(NSString *_Nonnull)channel appName:(NSString *_Nonnull)appName; |
| | | |
| | | /** |
| | | 用户登录状态发生变更的时候需要调用此接口,传入当前的用户的user_unique_id |
| | | |
| | | @param uniqueID 用户当前的user_unique_id |
| | | */ |
| | | - (void)setCurrentUserUniqueID:(NSString *_Nullable)uniqueID; |
| | | |
| | | /** |
| | | 用户登录状态发生变更的时候需要调用此接口,传入当前的用户的user_unique_id,并且关心SSID重新获取的时机 |
| | | |
| | | @param uniqueID 用户当前的user_unique_id |
| | | @param didRetriveBlock 重新获取SSID的回调 |
| | | */ |
| | | - (void)setCurrentUserUniqueID:(NSString *_Nullable)uniqueID |
| | | didRetriveSSIDBlock:(TTInstallDidRegisterBlock _Nullable)didRetriveBlock; |
| | | |
| | | //=============================== V3 Interface =================================== |
| | | /** |
| | | v3格式日志打点 |
| | | @param event 事件名称 |
| | | @param params 额外参数 |
| | | */ |
| | | + (void)eventV3:(NSString *_Nonnull)event params:(NSDictionary *_Nullable)params; |
| | | |
| | | |
| | | //================================== 钩子方法 ====================================== |
| | | /** |
| | | 捕获一条即将被缓存的埋点日志,做一些额外的事情,比如监控等 |
| | | |
| | | @param serviceID 本业务标示建议公司名.产品线.具体业务 比如bytedance.toutiao.ad |
| | | @param logHookBlock 一条即将被缓存的埋点日志 |
| | | */ |
| | | - (void)registerWithServiceID:(NSString *_Nonnull)serviceID willCacheOneLogBlock:(TTTrackerLogHookBlock _Nullable)logHookBlock; |
| | | |
| | | //=============================== Debug模式配置 ==================================== |
| | | /** |
| | | 设置当前环境是否为内测版本 |
| | | |
| | | @param isInHouseVersion 是否为内测版本 |
| | | */ |
| | | - (void)setIsInHouseVersion:(BOOL)isInHouseVersion; |
| | | |
| | | /** |
| | | 设置debug阶段埋点验证工具的域名和端口号,一般在应用的高级调试中设置 |
| | | |
| | | @param hostName 返回当前验证工具所在的pc主机的ip和端口号,形如:10.2.201.7:10304 */ |
| | | - (void)setDebugLogServerHost:(NSString *_Nonnull)hostName; |
| | | |
| | | /** |
| | | 设置debug阶段埋点验证工具的完整url地址,一般在二维码扫描回调里调用此方法 |
| | | |
| | | @param serverAddress 返回能连接到当前验证工具的完整url地址 */ |
| | | - (void)setDebugLogServerAddress:(NSString *_Nonnull)serverAddress; |
| | | |
| | | @end |
| | | |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: d0cb49a85674046a5a0ce3a7739cf324 |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | // |
| | | // TTTrackerHeader.h |
| | | // Tracker |
| | | // |
| | | // Created by fengyadong on 2017-3-14. |
| | | // Copyright (c) 2017 toutiao. All rights reserved. |
| | | // |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | |
| | | static const NSUInteger kTTTrackerSDKVersion = 201; |
| | | |
| | | /// 事件类型 |
| | | typedef NS_ENUM (NSInteger,TTTrackType) { |
| | | /// 普通事件 |
| | | TTTrackTypeEvent = 1, |
| | | /// launch或者terminate事件 |
| | | TTTrackTypeSession = 2 |
| | | }; |
| | | |
| | | /// 事件类型 |
| | | typedef NS_ENUM(NSInteger,TTTrackEventType) { |
| | | /// 正常事件 |
| | | TTTrackNormalEvent = 0, |
| | | /// CDN事件,已废弃 |
| | | TTTrackCDNEvent = 1 |
| | | }; |
| | | |
| | | /// 网络状态 |
| | | typedef NS_ENUM(NSInteger, TTInstallNetworkConnection) { |
| | | /// 初始状态 |
| | | TTInstallNetworkNone = -1, |
| | | /// 无网络连接 |
| | | TTInstallNetworkNoConnection = 0, |
| | | /// 移动网络连接 |
| | | TTInstallNetworkMobileConnnection = 1, |
| | | /// 2G网络连接 |
| | | TTInstallNetwork2GConnection = 2, |
| | | /// 3G网络连接 |
| | | TTInstallNetwork3GConnection = 3, |
| | | /// wifi网络连接 |
| | | TTInstallNetworkWifiConnection = 4, |
| | | /// 4G网络连接 |
| | | TTInstallNetwork4GConnection = 5 |
| | | }; |
| | | |
| | | /// 上报策略 |
| | | typedef NS_ENUM(NSInteger, TTTrackPolicy) { |
| | | /// 初始状态 |
| | | TTTrackPolicyNone = -1, |
| | | /// 批量发送,目前都是 |
| | | TTTrackPolicyBatch = 1, |
| | | /// 实时发送 |
| | | TTTrackPolicyCritical = 2, |
| | | }; |
| | | |
| | | /// 上报触发场景 |
| | | typedef NS_ENUM(NSUInteger, TTTrackerCleanerStartCleanFromType) { |
| | | /// app启动触发 |
| | | TTTrackerCleanerStartCleanFromInitAppKey, |
| | | /// 定时器触发 |
| | | TTTrackerCleanerStartCleanFromTimer, |
| | | /// 切到前台触发 |
| | | TTTrackerCleanerStartCleanFromAppWillEnterForground, |
| | | /// 切到后台触发 |
| | | TTTrackerCleanerStartCleanFromAppDidEnterBackground, |
| | | }; |
| | | |
| | | /// APP启动时上报启动原因,wiki: https://wiki.bytedance.com/pages/viewpage.action?pageId=55125960 |
| | | typedef NS_ENUM(NSUInteger, TTTrackerLaunchFrom) { |
| | | /// 初始状态 |
| | | TTTrackerLaunchFromInitialState = 0, |
| | | /// 用户手动点击进入app |
| | | TTTrackerLaunchFromUserClick = 1, |
| | | /// 用户通过push点击进入app |
| | | TTTrackerLaunchFromRemotePush = 2, |
| | | /// 用户通过widget点击进入app |
| | | TTTrackerLaunchFromWidget = 3, |
| | | /// 用户通过sptlight点击进入app |
| | | TTTrackerLaunchFromSpotlight = 4, |
| | | /// 用户通过外部app唤醒进入app |
| | | TTTrackerLaunchFromExternal = 5, |
| | | /// 用户手动切回前台 |
| | | TTTrackerLaunchFromBackground = 6, |
| | | }; |
| | | |
| | | /// url地址类型 |
| | | typedef NS_ENUM (NSInteger,TTTrackerURLType) { |
| | | /// 日志库配置 |
| | | TTTrackerURLTypeConfig = 0, |
| | | /// 日志库批量上报 |
| | | TTTrackerURLTypeBatchReport, |
| | | /// 日志库实时上报 |
| | | TTTrackerURLTypeImmediateReport |
| | | }; |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 91f9c8ee99c5841e0ab76d461505ff23 |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: edbc4b2f741ec48869f6f9036899d39d |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 2be0efbf43e9548df8c38737bb7e888e |
| | | folderAsset: yes |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | framework module TTTracker { |
| | | umbrella header "TTTracker.h" |
| | | |
| | | export * |
| | | module * { export * } |
| | | } |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 1f45356f62f5d4dd0b4953aa793f5621 |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 8d982b261e1d2458c9c9a813f0531ca7 |
| | | timeCreated: 1534859534 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | /* |
| | | * | | | | \ \ / / | | | | / _______| |
| | | * | |____| | \ \/ / | |____| | / / |
| | | * | |____| | \ / | |____| | | | _____ |
| | | * | | | | / \ | | | | | | |____ | |
| | | * | | | | / /\ \ | | | | \ \______| | |
| | | * | | | | /_/ \_\ | | | | \_________| |
| | | * |
| | | * Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved. |
| | | */ |
| | | |
| | | #define JPUSH_VERSION_NUMBER 3.2.1 |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | |
| | | @class CLRegion; |
| | | @class UILocalNotification; |
| | | @class CLLocation; |
| | | @class UNNotificationCategory; |
| | | @class UNNotificationSettings; |
| | | @class UNNotificationRequest; |
| | | @class UNNotification; |
| | | @protocol JPUSHRegisterDelegate; |
| | | @protocol JPUSHGeofenceDelegate; |
| | | |
| | | typedef void (^JPUSHTagsOperationCompletion)(NSInteger iResCode, NSSet *iTags, NSInteger seq); |
| | | typedef void (^JPUSHTagValidOperationCompletion)(NSInteger iResCode, NSSet *iTags, NSInteger seq, BOOL isBind); |
| | | typedef void (^JPUSHAliasOperationCompletion)(NSInteger iResCode, NSString *iAlias, NSInteger seq); |
| | | |
| | | extern NSString *const kJPFNetworkIsConnectingNotification; // 正在连接中 |
| | | extern NSString *const kJPFNetworkDidSetupNotification; // 建立连接 |
| | | extern NSString *const kJPFNetworkDidCloseNotification; // 关闭连接 |
| | | extern NSString *const kJPFNetworkDidRegisterNotification; // 注册成功 |
| | | extern NSString *const kJPFNetworkFailedRegisterNotification; //注册失败 |
| | | extern NSString *const kJPFNetworkDidLoginNotification; // 登录成功 |
| | | extern NSString *const kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS) |
| | | extern NSString *const kJPFServiceErrorNotification; // 错误提示 |
| | | |
| | | typedef NS_OPTIONS(NSUInteger, JPAuthorizationOptions) { |
| | | JPAuthorizationOptionNone = 0, // the application may not present any UI upon a notification being received |
| | | JPAuthorizationOptionBadge = (1 << 0), // the application may badge its icon upon a notification being received |
| | | JPAuthorizationOptionSound = (1 << 1), // the application may play a sound upon a notification being received |
| | | JPAuthorizationOptionAlert = (1 << 2), // the application may display an alert upon a notification being received |
| | | JPAuthorizationOptionCarPlay = (1 << 3), // The ability to display notifications in a CarPlay environment. |
| | | JPAuthorizationOptionCriticalAlert NS_AVAILABLE_IOS(12.0) = (1 << 4) , //The ability to play sounds for critical alerts. |
| | | JPAuthorizationOptionProvidesAppNotificationSettings NS_AVAILABLE_IOS(12.0) = (1 << 5) , //An option indicating the system should display a button for in-app notification settings. |
| | | JPAuthorizationOptionProvisional NS_AVAILABLE_IOS(12.0) = (1 << 6) , //The ability to post noninterrupting notifications provisionally to the Notification Center. |
| | | |
| | | }; |
| | | |
| | | /*! |
| | | * 通知注册实体类 |
| | | */ |
| | | @interface JPUSHRegisterEntity : NSObject |
| | | |
| | | /*! |
| | | * 支持的类型 |
| | | * badge,sound,alert |
| | | */ |
| | | @property (nonatomic, assign) NSInteger types; |
| | | /*! |
| | | * 注入的类别 |
| | | * iOS10 UNNotificationCategory |
| | | * iOS8-iOS9 UIUserNotificationCategory |
| | | */ |
| | | @property (nonatomic, strong) NSSet *categories; |
| | | @end |
| | | |
| | | /*! |
| | | * 进行删除、查找推送实体类 |
| | | */ |
| | | @interface JPushNotificationIdentifier : NSObject<NSCopying, NSCoding> |
| | | |
| | | @property (nonatomic, copy) NSArray<NSString *> *identifiers; // 推送的标识数组 |
| | | @property (nonatomic, copy) UILocalNotification *notificationObj NS_DEPRECATED_IOS(4_0, 10_0); // iOS10以下可以传UILocalNotification对象数据,iOS10以上无效 |
| | | @property (nonatomic, assign) BOOL delivered NS_AVAILABLE_IOS(10_0); // 在通知中心显示的或待推送的标志,默认为NO,YES表示在通知中心显示的,NO表示待推送的 |
| | | @property (nonatomic, copy) void (^findCompletionHandler)(NSArray *results); // 用于查询回调,调用[findNotification:]方法前必须设置,results为返回相应对象数组,iOS10以下返回UILocalNotification对象数组;iOS10以上根据delivered传入值返回UNNotification或UNNotificationRequest对象数组(delivered传入YES,则返回UNNotification对象数组,否则返回UNNotificationRequest对象数组) |
| | | |
| | | @end |
| | | |
| | | /*! |
| | | * 推送通知声音实体类 |
| | | * iOS10以上有效 |
| | | */ |
| | | @interface JPushNotificationSound : NSObject <NSCopying, NSCoding> |
| | | @property (nonatomic, copy) NSString *soundName; //普通通知铃声 |
| | | @property (nonatomic, copy) NSString *criticalSoundName NS_AVAILABLE_IOS(12.0); //警告通知铃声 |
| | | @property (nonatomic, assign) float criticalSoundVolume NS_AVAILABLE_IOS(12.0); //警告通知铃声音量,有效值在0~1之间,默认为1 |
| | | @end |
| | | |
| | | |
| | | /*! |
| | | * 推送内容实体类 |
| | | */ |
| | | @interface JPushNotificationContent : NSObject<NSCopying, NSCoding> |
| | | |
| | | @property (nonatomic, copy) NSString *title; // 推送标题 |
| | | @property (nonatomic, copy) NSString *subtitle; // 推送副标题 |
| | | @property (nonatomic, copy) NSString *body; // 推送内容 |
| | | @property (nonatomic, copy) NSNumber *badge; // 角标的数字。如果不需要改变角标传@(-1) |
| | | @property (nonatomic, copy) NSString *action NS_DEPRECATED_IOS(8_0, 10_0); // 弹框的按钮显示的内容(IOS 8默认为"打开", 其他默认为"启动",iOS10以上无效) |
| | | @property (nonatomic, copy) NSString *categoryIdentifier; // 行为分类标识 |
| | | @property (nonatomic, copy) NSDictionary *userInfo; // 本地推送时可以设置userInfo来增加附加信息,远程推送时设置的payload推送内容作为此userInfo |
| | | @property (nonatomic, copy) NSString *sound; // 声音名称,不设置则为默认声音 |
| | | @property (nonatomic, copy) JPushNotificationSound *soundSetting NS_AVAILABLE_IOS(10.0); //推送声音实体 |
| | | @property (nonatomic, copy) NSArray *attachments NS_AVAILABLE_IOS(10_0); // 附件,iOS10以上有效,需要传入UNNotificationAttachment对象数组类型 |
| | | @property (nonatomic, copy) NSString *threadIdentifier NS_AVAILABLE_IOS(10_0); // 线程或与推送请求相关对话的标识,iOS10以上有效,可用来对推送进行分组 |
| | | @property (nonatomic, copy) NSString *launchImageName NS_AVAILABLE_IOS(10_0); // 启动图片名,iOS10以上有效,从推送启动时将会用到 |
| | | @property (nonatomic, copy) NSString *summaryArgument NS_AVAILABLE_IOS(12.0); //插入到通知摘要中的部分参数。iOS12以上有效。 |
| | | @property (nonatomic, assign) NSUInteger summaryArgumentCount NS_AVAILABLE_IOS(12.0); //插入到通知摘要中的项目数。iOS12以上有效。 |
| | | |
| | | @end |
| | | |
| | | |
| | | /*! |
| | | * 推送触发方式实体类 |
| | | * 注:dateComponents、timeInterval、region在iOS10以上可选择其中一个参数传入有效值,如果同时传入值会根据优先级I、II、III使其中一种触发方式生效,fireDate为iOS10以下根据时间触发时须传入的参数 |
| | | */ |
| | | @interface JPushNotificationTrigger : NSObject<NSCopying, NSCoding> |
| | | |
| | | @property (nonatomic, assign) BOOL repeat; // 设置是否重复,默认为NO |
| | | @property (nonatomic, copy) NSDate *fireDate NS_DEPRECATED_IOS(2_0, 10_0); // 用来设置触发推送的时间,iOS10以上无效 |
| | | @property (nonatomic, copy) CLRegion *region NS_AVAILABLE_IOS(8_0); // 用来设置触发推送的位置,iOS8以上有效,iOS10以上优先级为I,应用需要有允许使用定位的授权 |
| | | @property (nonatomic, copy) NSDateComponents *dateComponents NS_AVAILABLE_IOS(10_0); // 用来设置触发推送的日期时间,iOS10以上有效,优先级为II |
| | | @property (nonatomic, assign) NSTimeInterval timeInterval NS_AVAILABLE_IOS(10_0); // 用来设置触发推送的时间,iOS10以上有效,优先级为III |
| | | |
| | | @end |
| | | |
| | | /*! |
| | | * 注册或更新推送实体类 |
| | | */ |
| | | @interface JPushNotificationRequest : NSObject<NSCopying, NSCoding> |
| | | |
| | | @property (nonatomic, copy) NSString *requestIdentifier; // 推送请求标识 |
| | | @property (nonatomic, copy) JPushNotificationContent *content; // 设置推送的具体内容 |
| | | @property (nonatomic, copy) JPushNotificationTrigger *trigger; // 设置推送的触发方式 |
| | | @property (nonatomic, copy) void (^completionHandler)(id result); // 注册或更新推送成功回调,iOS10以上成功则result为UNNotificationRequest对象,失败则result为nil;iOS10以下成功result为UILocalNotification对象,失败则result为nil |
| | | |
| | | @end |
| | | |
| | | /*! |
| | | * JPush 核心头文件 |
| | | */ |
| | | @interface JPUSHService : NSObject |
| | | |
| | | |
| | | ///---------------------------------------------------- |
| | | /// @name Setup 启动相关 |
| | | ///---------------------------------------------------- |
| | | |
| | | |
| | | /*! |
| | | * @abstract 启动SDK |
| | | * |
| | | * @param launchingOption 启动参数. |
| | | * @param appKey 一个JPush 应用必须的,唯一的标识. 请参考 JPush 相关说明文档来获取这个标识. |
| | | * @param channel 发布渠道. 可选. |
| | | * @param isProduction 是否生产环境. 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES. |
| | | * App 证书环境取决于profile provision的配置,此处建议与证书环境保持一致. |
| | | * |
| | | * @discussion 提供SDK启动必须的参数, 来启动 SDK. |
| | | * 此接口必须在 App 启动时调用, 否则 JPush SDK 将无法正常工作. |
| | | */ |
| | | + (void)setupWithOption:(NSDictionary *)launchingOption |
| | | appKey:(NSString *)appKey |
| | | channel:(NSString *)channel |
| | | apsForProduction:(BOOL)isProduction; |
| | | |
| | | /*! |
| | | * @abstract 启动SDK |
| | | * |
| | | * @param launchingOption 启动参数. |
| | | * @param appKey 一个JPush 应用必须的,唯一的标识. 请参考 JPush 相关说明文档来获取这个标识. |
| | | * @param channel 发布渠道. 可选. |
| | | * @param isProduction 是否生产环境. 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES. |
| | | * App 证书环境取决于profile provision的配置,此处建议与证书环境保持一致. |
| | | * @param advertisingId 广告标识符(IDFA) 如果不需要使用IDFA,传nil. |
| | | * |
| | | * @discussion 提供SDK启动必须的参数, 来启动 SDK. |
| | | * 此接口必须在 App 启动时调用, 否则 JPush SDK 将无法正常工作. |
| | | */ |
| | | + (void)setupWithOption:(NSDictionary *)launchingOption |
| | | appKey:(NSString *)appKey |
| | | channel:(NSString *)channel |
| | | apsForProduction:(BOOL)isProduction |
| | | advertisingIdentifier:(NSString *)advertisingId; |
| | | |
| | | |
| | | ///---------------------------------------------------- |
| | | /// @name APNs about 通知相关 |
| | | ///---------------------------------------------------- |
| | | |
| | | /*! |
| | | * @abstract 注册要处理的远程通知类型 |
| | | * |
| | | * @param types 通知类型 |
| | | * @param categories 类别组 |
| | | * |
| | | */ |
| | | + (void)registerForRemoteNotificationTypes:(NSUInteger)types |
| | | categories:(NSSet *)categories; |
| | | /*! |
| | | * @abstract 新版本的注册方法(兼容iOS10) |
| | | * |
| | | * @param config 注册通知配置 |
| | | * @param delegate 代理 |
| | | * |
| | | */ |
| | | + (void)registerForRemoteNotificationConfig:(JPUSHRegisterEntity *)config delegate:(id<JPUSHRegisterDelegate>)delegate; |
| | | |
| | | |
| | | + (void)registerDeviceToken:(NSData *)deviceToken; |
| | | |
| | | |
| | | /*! |
| | | * @abstract 处理收到的 APNs 消息 |
| | | */ |
| | | + (void)handleRemoteNotification:(NSDictionary *)remoteInfo; |
| | | |
| | | /*! |
| | | * Tags操作接口 |
| | | * 支持增加/覆盖/删除/清空/查询操作 |
| | | * 详情请参考文档:https://docs.jiguang.cn/jpush/client/iOS/ios_api/) |
| | | */ |
| | | |
| | | /** |
| | | 增加tags |
| | | |
| | | @param tags 需要增加的tags集合 |
| | | @param completion 响应回调 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)addTags:(NSSet<NSString *> *)tags |
| | | completion:(JPUSHTagsOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 覆盖tags |
| | | 调用该接口会覆盖用户所有的tags |
| | | |
| | | @param tags 需要设置的tags集合 |
| | | @param completion 响应回调 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)setTags:(NSSet<NSString *> *)tags |
| | | completion:(JPUSHTagsOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 删除指定tags |
| | | |
| | | @param tags 需要删除的tags集合 |
| | | @param completion 响应回调 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)deleteTags:(NSSet<NSString *> *)tags |
| | | completion:(JPUSHTagsOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 清空所有tags |
| | | @param completion 响应回调 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)cleanTags:(JPUSHTagsOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 查询全部tags |
| | | |
| | | @param completion 响应回调,请在回调中获取查询结果 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)getAllTags:(JPUSHTagsOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 验证tag是否绑定 |
| | | |
| | | @param completion 响应回调,回调中查看是否绑定 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)validTag:(NSString *)tag |
| | | completion:(JPUSHTagValidOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 设置Alias |
| | | |
| | | @param alias 需要设置的alias |
| | | @param completion 响应回调 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)setAlias:(NSString *)alias |
| | | completion:(JPUSHAliasOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 删除alias |
| | | |
| | | @param completion 响应回调 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)deleteAlias:(JPUSHAliasOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | /** |
| | | 查询当前alias |
| | | |
| | | @param completion 响应回调 |
| | | @param seq 请求序列号 |
| | | */ |
| | | + (void)getAlias:(JPUSHAliasOperationCompletion)completion |
| | | seq:(NSInteger)seq; |
| | | |
| | | |
| | | /*! |
| | | * @abstract 过滤掉无效的 tags |
| | | * |
| | | * @discussion 如果 tags 数量超过限制数量, 则返回靠前的有效的 tags. |
| | | * 建议设置 tags 前用此接口校验. SDK 内部也会基于此接口来做过滤. |
| | | */ |
| | | + (NSSet *)filterValidTags:(NSSet *)tags; |
| | | |
| | | ///---------------------------------------------------- |
| | | /// @name Stats 统计功能 |
| | | ///---------------------------------------------------- |
| | | |
| | | /*! |
| | | * @abstract 开始记录页面停留 |
| | | * |
| | | * @param pageName 页面名称 |
| | | * @discussion JCore 1.1.8 版本后,如需统计页面流,请使用 JAnalytics |
| | | */ |
| | | + (void)startLogPageView:(NSString *)pageName __attribute__((deprecated("JCore 1.1.8 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 停止记录页面停留 |
| | | * |
| | | * @param pageName 页面 |
| | | * @discussion JCore 1.1.8 版本后,如需统计页面流,请使用 JAnalytics |
| | | */ |
| | | + (void)stopLogPageView:(NSString *)pageName __attribute__((deprecated("JCore 1.1.8 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 直接上报在页面的停留时间 |
| | | * |
| | | * @param pageName 页面 |
| | | * @param seconds 停留的秒数 |
| | | * @discussion JCore 1.1.8 版本后,如需统计页面流,请使用 JAnalytics |
| | | */ |
| | | + (void)beginLogPageView:(NSString *)pageName duration:(int)seconds __attribute__((deprecated("JCore 1.1.8 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 开启Crash日志收集 |
| | | * |
| | | * @discussion 默认是关闭状态. |
| | | */ |
| | | + (void)crashLogON; |
| | | |
| | | /*! |
| | | * @abstract 地理位置上报 |
| | | * |
| | | * @param latitude 纬度. |
| | | * @param longitude 经度. |
| | | * |
| | | */ |
| | | + (void)setLatitude:(double)latitude longitude:(double)longitude; |
| | | |
| | | /*! |
| | | * @abstract 地理位置上报 |
| | | * |
| | | * @param location 直接传递 CLLocation * 型的地理信息 |
| | | * |
| | | * @discussion 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h> |
| | | */ |
| | | + (void)setLocation:(CLLocation *)location; |
| | | |
| | | /** |
| | | 设置地理围栏的最大个数 |
| | | 默认值为 10 ,iOS系统默认地理围栏最大个数为20 |
| | | @param count 个数 count |
| | | */ |
| | | + (void)setGeofenecMaxCount:(NSInteger)count; |
| | | /** |
| | | 注册地理围栏的代理 |
| | | |
| | | @param delegate 代理 |
| | | @param launchOptions app启动完成是收到的字段参数 |
| | | */ |
| | | + (void)registerLbsGeofenceDelegate:(id<JPUSHGeofenceDelegate>)delegate withLaunchOptions:(NSDictionary *)launchOptions; |
| | | |
| | | /** |
| | | 删除地理围栏 |
| | | |
| | | @param geofenceId 地理围栏id |
| | | */ |
| | | + (void)removeGeofenceWithIdentifier:(NSString *)geofenceId; |
| | | |
| | | ///---------------------------------------------------- |
| | | /// @name Local Notification 本地通知 |
| | | ///---------------------------------------------------- |
| | | /*! |
| | | * @abstract 注册或更新推送 (支持iOS10,并兼容iOS10以下版本) |
| | | * |
| | | * JPush 2.1.9新接口 |
| | | * @param request JPushNotificationRequest类型,设置推送的属性,设置已有推送的request.requestIdentifier即更新已有的推送,否则为注册新推送,更新推送仅仅在iOS10以上有效,结果通过request.completionHandler返回 |
| | | * @discussion 旧的注册本地推送接口被废弃,使用此接口可以替换 |
| | | * |
| | | */ |
| | | + (void)addNotification:(JPushNotificationRequest *)request; |
| | | |
| | | /*! |
| | | * @abstract 移除推送 (支持iOS10,并兼容iOS10以下版本) |
| | | * |
| | | * JPush 2.1.9新接口 |
| | | * @param identifier JPushNotificationIdentifier类型,iOS10以上identifier设置为nil,则移除所有在通知中心显示推送和待推送请求,也可以通过设置identifier.delivered和identifier.identifiers来移除相应在通知中心显示推送或待推送请求,identifier.identifiers如果设置为nil或空数组则移除相应标志下所有在通知中心显示推送或待推送请求;iOS10以下identifier设置为nil,则移除所有推送,identifier.delivered属性无效,另外可以通过identifier.notificationObj传入特定推送对象来移除此推送。 |
| | | * @discussion 旧的所有删除推送接口被废弃,使用此接口可以替换 |
| | | * |
| | | */ |
| | | + (void)removeNotification:(JPushNotificationIdentifier *)identifier; |
| | | |
| | | /*! |
| | | * @abstract 查找推送 (支持iOS10,并兼容iOS10以下版本) |
| | | * |
| | | * JPush 2.1.9新接口 |
| | | * @param identifier JPushNotificationIdentifier类型,iOS10以上可以通过设置identifier.delivered和identifier.identifiers来查找相应在通知中心显示推送或待推送请求,identifier.identifiers如果设置为nil或空数组则返回相应标志下所有在通知中心显示推送或待推送请求;iOS10以下identifier.delivered属性无效,identifier.identifiers如果设置nil或空数组则返回所有未触发的推送。须要设置identifier.findCompletionHandler回调才能得到查找结果,通过(NSArray *results)返回相应对象数组。 |
| | | * @discussion 旧的查找推送接口被废弃,使用此接口可以替换 |
| | | * |
| | | */ |
| | | + (void)findNotification:(JPushNotificationIdentifier *)identifier; |
| | | |
| | | /*! |
| | | * @abstract 本地推送,最多支持64个 |
| | | * |
| | | * @param fireDate 本地推送触发的时间 |
| | | * @param alertBody 本地推送需要显示的内容 |
| | | * @param badge 角标的数字。如果不需要改变角标传-1 |
| | | * @param alertAction 弹框的按钮显示的内容(IOS 8默认为"打开", 其他默认为"启动") |
| | | * @param notificationKey 本地推送标示符 |
| | | * @param userInfo 自定义参数,可以用来标识推送和增加附加信息 |
| | | * @param soundName 自定义通知声音,设置为nil为默认声音 |
| | | * |
| | | * @discussion 最多支持 64 个定义,此方法被[addNotification:]方法取代 |
| | | */ |
| | | + (UILocalNotification *)setLocalNotification:(NSDate *)fireDate |
| | | alertBody:(NSString *)alertBody |
| | | badge:(int)badge |
| | | alertAction:(NSString *)alertAction |
| | | identifierKey:(NSString *)notificationKey |
| | | userInfo:(NSDictionary *)userInfo |
| | | soundName:(NSString *)soundName __attribute__((deprecated("JPush 2.1.9 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 本地推送 (支持 iOS8 新参数) |
| | | * |
| | | * IOS8新参数 |
| | | * @param region 自定义参数 |
| | | * @param regionTriggersOnce 自定义参数 |
| | | * @param category 自定义参数 |
| | | * @discussion 此方法被[addNotification:]方法取代 |
| | | */ |
| | | + (UILocalNotification *)setLocalNotification:(NSDate *)fireDate |
| | | alertBody:(NSString *)alertBody |
| | | badge:(int)badge |
| | | alertAction:(NSString *)alertAction |
| | | identifierKey:(NSString *)notificationKey |
| | | userInfo:(NSDictionary *)userInfo |
| | | soundName:(NSString *)soundName |
| | | region:(CLRegion *)region |
| | | regionTriggersOnce:(BOOL)regionTriggersOnce |
| | | category:(NSString *)category NS_AVAILABLE_IOS(8_0) __attribute__((deprecated("JPush 2.1.9 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 前台展示本地推送 |
| | | * |
| | | * @param notification 本地推送对象 |
| | | * @param notificationKey 需要前台显示的本地推送通知的标示符 |
| | | * |
| | | * @discussion 默认App在前台运行时不会进行弹窗,在程序接收通知调用此接口可实现指定的推送弹窗。--iOS10以下还可继续使用,iOS10以上在[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:]方法中调用completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);即可 |
| | | */ |
| | | + (void)showLocalNotificationAtFront:(UILocalNotification *)notification |
| | | identifierKey:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期"))); |
| | | /*! |
| | | * @abstract 删除本地推送定义 |
| | | * |
| | | * @param notificationKey 本地推送标示符 |
| | | * @discussion 此方法被[removeNotification:]方法取代 |
| | | */ |
| | | + (void)deleteLocalNotificationWithIdentifierKey:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 删除本地推送定义 |
| | | * @discussion 此方法被[removeNotification:]方法取代 |
| | | */ |
| | | + (void)deleteLocalNotification:(UILocalNotification *)localNotification __attribute__((deprecated("JPush 2.1.9 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 获取指定通知 |
| | | * |
| | | * @param notificationKey 本地推送标示符 |
| | | * @return 本地推送对象数组, [array count]为0时表示没找到 |
| | | * @discussion 此方法被[findNotification:]方法取代 |
| | | */ |
| | | + (NSArray *)findLocalNotificationWithIdentifier:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期"))); |
| | | |
| | | /*! |
| | | * @abstract 清除所有本地推送对象 |
| | | * @discussion 此方法被[removeNotification:]方法取代 |
| | | */ |
| | | + (void)clearAllLocalNotifications __attribute__((deprecated("JPush 2.1.9 版本已过期"))); |
| | | |
| | | |
| | | ///---------------------------------------------------- |
| | | /// @name Server badge 服务器端 badge 功能 |
| | | ///---------------------------------------------------- |
| | | |
| | | /*! |
| | | * @abstract 设置角标(到服务器) |
| | | * |
| | | * @param value 新的值. 会覆盖服务器上保存的值(这个用户) |
| | | * |
| | | * @discussion 本接口不会改变应用本地的角标值. |
| | | * 本地仍须调用 UIApplication:setApplicationIconBadgeNumber 函数来设置脚标. |
| | | * |
| | | * 本接口用于配合 JPush 提供的服务器端角标功能. |
| | | * 该功能解决的问题是, 服务器端推送 APNs 时, 并不知道客户端原来已经存在的角标是多少, 指定一个固定的数字不太合理. |
| | | * |
| | | * JPush 服务器端脚标功能提供: |
| | | * |
| | | * - 通过本 API 把当前客户端(当前这个用户的) 的实际 badge 设置到服务器端保存起来; |
| | | * - 调用服务器端 API 发 APNs 时(通常这个调用是批量针对大量用户), |
| | | * 使用 "+1" 的语义, 来表达需要基于目标用户实际的 badge 值(保存的) +1 来下发通知时带上新的 badge 值; |
| | | */ |
| | | + (BOOL)setBadge:(NSInteger)value; |
| | | |
| | | /*! |
| | | * @abstract 重置脚标(为0) |
| | | * |
| | | * @discussion 相当于 [setBadge:0] 的效果. |
| | | * 参考 [JPUSHService setBadge:] 说明来理解其作用. |
| | | */ |
| | | + (void)resetBadge; |
| | | |
| | | ///---------------------------------------------------- |
| | | /// @name Other Feature 其他功能 |
| | | ///---------------------------------------------------- |
| | | |
| | | /*! |
| | | * @abstract 设置手机号码(到服务器) |
| | | * |
| | | * @param mobileNumber 手机号码. 会与用户信息一一对应。可为空,为空则清除号码 |
| | | * @param completion 响应回调。成功则error为空,失败则error带有错误码及错误信息 |
| | | * |
| | | * @discussion 设置手机号码后,可实现“推送不到短信到”的通知方式,提高推送达到率。结果信息通过completion异步返回,也可将completion设置为nil不处理结果信息。 |
| | | * |
| | | */ |
| | | + (void)setMobileNumber:(NSString *)mobileNumber completion:(void (^)(NSError *error))completion; |
| | | |
| | | ///---------------------------------------------------- |
| | | /// @name Logs and others 日志与其他 |
| | | ///---------------------------------------------------- |
| | | |
| | | /*! |
| | | * @abstract JPush标识此设备的 registrationID |
| | | * |
| | | * @discussion SDK注册成功后, 调用此接口获取到 registrationID 才能够获取到. |
| | | * |
| | | * JPush 支持根据 registrationID 来进行推送. |
| | | * 如果你需要此功能, 应该通过此接口获取到 registrationID 后, 上报到你自己的服务器端, 并保存下来. |
| | | * registrationIDCompletionHandler:是新增的获取registrationID的方法,需要在block中获取registrationID,resCode为返回码,模拟器调用此接口resCode返回1011,registrationID返回nil. |
| | | * 更多的理解请参考 JPush 的文档网站. |
| | | */ |
| | | + (NSString *)registrationID; |
| | | |
| | | + (void)registrationIDCompletionHandler:(void(^)(int resCode,NSString *registrationID))completionHandler; |
| | | |
| | | /*! |
| | | * @abstract 打开日志级别到 Debug |
| | | * |
| | | * @discussion JMessage iOS 的日志系统参考 Android 设计了级别. |
| | | * 从低到高是: Verbose, Debug, Info, Warning, Error. |
| | | * 对日志级别的进一步理解, 请参考 Android 相关的说明. |
| | | * |
| | | * SDK 默认开启的日志级别为: Info. 只显示必要的信息, 不打印调试日志. |
| | | * |
| | | * 请在SDK启动后调用本接口,调用本接口可打开日志级别为: Debug, 打印调试日志. |
| | | */ |
| | | + (void)setDebugMode; |
| | | |
| | | /*! |
| | | * @abstract 关闭日志 |
| | | * |
| | | * @discussion 关于日志级别的说明, 参考 [JPUSHService setDebugMode] |
| | | * |
| | | * 虽说是关闭日志, 但还是会打印 Warning, Error 日志. 这二种日志级别, 在程序运行正常时, 不应有打印输出. |
| | | * |
| | | * 建议在发布的版本里, 调用此接口, 关闭掉日志打印. |
| | | */ |
| | | + (void)setLogOFF; |
| | | |
| | | ///---------------------------------------------------- |
| | | ///********************下列方法已过期******************** |
| | | ///**************请使用新版tag/alias操作接口************** |
| | | ///---------------------------------------------------- |
| | | /// @name Tag alias setting 设置别名与标签 |
| | | ///---------------------------------------------------- |
| | | |
| | | /*! |
| | | * 下面的接口是可选的 |
| | | * 设置标签和(或)别名(若参数为nil,则忽略;若是空对象,则清空;详情请参考文档:https://docs.jiguang.cn/jpush/client/iOS/ios_api/) |
| | | * setTags:alias:fetchCompletionHandle:是新的设置标签别名的方法,不再需要显示声明回调函数,只需要在block里面处理设置结果即可. |
| | | * WARN: 使用block时需要注意循环引用问题 |
| | | */ |
| | | + (void) setTags:(NSSet *)tags |
| | | alias:(NSString *)alias |
| | | callbackSelector:(SEL)cbSelector |
| | | target:(id)theTarget __attribute__((deprecated("JPush 2.1.1 版本已过期"))); |
| | | + (void) setTags:(NSSet *)tags |
| | | alias:(NSString *)alias |
| | | callbackSelector:(SEL)cbSelector |
| | | object:(id)theTarget __attribute__((deprecated("JPush 3.0.6 版本已过期"))); |
| | | + (void) setTags:(NSSet *)tags |
| | | callbackSelector:(SEL)cbSelector |
| | | object:(id)theTarget __attribute__((deprecated("JPush 3.0.6 版本已过期"))); |
| | | + (void)setTags:(NSSet *)tags |
| | | alias:(NSString *)alias |
| | | fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler __attribute__((deprecated("JPush 3.0.6 版本已过期"))); |
| | | + (void) setTags:(NSSet *)tags |
| | | aliasInbackground:(NSString *)alias __attribute__((deprecated("JPush 3.0.6 版本已过期"))); |
| | | + (void)setAlias:(NSString *)alias |
| | | callbackSelector:(SEL)cbSelector |
| | | object:(id)theTarget __attribute__((deprecated("JPush 3.0.6 版本已过期"))); |
| | | |
| | | @end |
| | | |
| | | @class UNUserNotificationCenter; |
| | | @class UNNotificationResponse; |
| | | |
| | | @protocol JPUSHRegisterDelegate <NSObject> |
| | | |
| | | /* |
| | | * @brief handle UserNotifications.framework [willPresentNotification:withCompletionHandler:] |
| | | * @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心 |
| | | * @param notification 前台得到的的通知对象 |
| | | * @param completionHandler 该callback中的options 请使用UNNotificationPresentationOptions |
| | | */ |
| | | - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger options))completionHandler; |
| | | /* |
| | | * @brief handle UserNotifications.framework [didReceiveNotificationResponse:withCompletionHandler:] |
| | | * @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心 |
| | | * @param response 通知响应对象 |
| | | * @param completionHandler |
| | | */ |
| | | - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler; |
| | | |
| | | /* |
| | | * @brief handle UserNotifications.framework [openSettingsForNotification:] |
| | | * @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心 |
| | | * @param notification 当前管理的通知对象 |
| | | */ |
| | | - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification NS_AVAILABLE_IOS(12.0); |
| | | |
| | | @end |
| | | |
| | | @protocol JPUSHGeofenceDelegate <NSObject> |
| | | |
| | | /** |
| | | 进入地理围栏区域 |
| | | |
| | | @param geofenceId 地理围栏id |
| | | @param userInfo 地理围栏触发时返回的信息 |
| | | @param error 错误信息 |
| | | */ |
| | | - (void)jpushGeofenceIdentifer:(NSString * _Nonnull)geofenceId didEnterRegion:(NSDictionary * _Nullable)userInfo error:(NSError * _Nullable)error; |
| | | |
| | | /** |
| | | 离开地理围栏区域 |
| | | |
| | | @param geofenceId 地理围栏id |
| | | @param userInfo 地理围栏触发时返回的信息 |
| | | @param error 错误信息 |
| | | */ |
| | | - (void)jpushGeofenceIdentifer:(NSString * _Nonnull)geofenceId didExitRegion:(NSDictionary * _Nullable)userInfo error:(NSError * _Nullable)error; |
| | | |
| | | @end |
New file |
| | |
| | | /* |
| | | * | | | | \ \ / / | | | | / _______| |
| | | * | |____| | \ \/ / | |____| | / / |
| | | * | |____| | \ / | |____| | | | _____ |
| | | * | | | | / \ | | | | | | |____ | |
| | | * | | | | / /\ \ | | | | \ \______| | |
| | | * | | | | /_/ \_\ | | | | \_________| |
| | | * |
| | | * Copyright (c) 2017 Shenzhen HXHG. All rights reserved. |
| | | */ |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | |
| | | #define JPUSH_EXTENSION_VERSION_NUMBER 1.1.2 |
| | | |
| | | @class UNNotificationRequest; |
| | | |
| | | @interface JPushNotificationExtensionService : NSObject |
| | | |
| | | |
| | | /** |
| | | 设置appkey(需要与main target中的appkey相同) |
| | | */ |
| | | + (void)jpushSetAppkey:(NSString *)appkey; |
| | | |
| | | /** |
| | | apns送达 |
| | | @param request apns请求 |
| | | @param completion 回调 |
| | | */ |
| | | + (void)jpushReceiveNotificationRequest:(UNNotificationRequest *)request with:(void (^)(void))completion; |
| | | |
| | | /** |
| | | 关闭日志 |
| | | 默认为开启 |
| | | 建议发布时关闭以减少不必要的IO |
| | | */ |
| | | + (void)setLogOff; |
| | | |
| | | |
| | | @end |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| | | <plist version="1.0"> |
| | | <dict> |
| | | <key>JPush_AppKey</key> |
| | | <string>111a5f817592ddc68edc802c</string> |
| | | <key>TTTrack_AppID</key> |
| | | <string>155761</string> |
| | | <key>TrackingIO_AppKey</key> |
| | | <string>12aef4c284c6996703765fe9f7422428</string> |
| | | </dict> |
| | | </plist> |
New file |
| | |
| | | // |
| | | // UniversalSDK.h |
| | | // Unity-iPhone |
| | | // |
| | | // Created by 蔡瀚 on 2018/4/24. |
| | | // |
| | | |
| | | #ifndef __UNIVERSALSDK_H_ |
| | | #define __UNIVERSALSDK_H_ |
| | | |
| | | #import <Foundation/Foundation.h> |
| | | #import <UIKit/UIKit.h> |
| | | |
| | | #define UNITY_OBJ_NAME "SDKUtility" |
| | | #define UNITY_FUNC_NAME "HandleSdkMessage" |
| | | |
| | | #define S2U_BatteryLevel 1 |
| | | #define S2U_BatteryCharging 2 |
| | | #define S2U_DeviceInfo 3 |
| | | #define S2U_PushClientID 4 |
| | | #define S2U_FreePlatformInitOk 10 |
| | | #define S2U_FreePlatformInitFail 11 |
| | | #define S2U_FreePlatformLoginOk 12 |
| | | #define S2U_FreePlatformLoginFail 13 |
| | | #define S2U_FreePlatformLoginCancel 14 |
| | | #define S2U_FreePlatformLogoutOk 15 |
| | | #define S2U_FreePlatformLogoutFail 16 |
| | | #define S2U_FreePlatformSwitchAccountOk 17 |
| | | #define S2U_FreePlatformPayOk 18 |
| | | #define S2U_FreePlatformPayFail 19 |
| | | #define S2U_FreePlatformPayCancel 20 |
| | | #define S2U_FreePlatformRegisterOk 21 |
| | | #define S2U_SdkInitComplete 90 |
| | | |
| | | #define U2S_BatteryListenStart 1 |
| | | #define U2S_BatteryListenStop 2 |
| | | #define U2S_CopyContent 7 |
| | | #define U2S_OpenWebView 8 |
| | | #define U2S_Init 9 |
| | | #define U2S_FreePlatformInit 100 |
| | | #define U2S_FreePlatformLogin 101 |
| | | #define U2S_FreePlatformLogout 102 |
| | | #define U2S_FreePlatformSwitchAccount 103 |
| | | #define U2S_FreePlatformPay 104 |
| | | #define U2S_PayFinished 105 |
| | | #define U2S_RoleLogin 107 |
| | | #define U2S_JPushAddLocalMessage 200 |
| | | #define U2S_JPushRemoveLocalMessage 201 |
| | | #define U2S_MakeKeyAndVisible 300 |
| | | |
| | | #define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO) |
| | | |
| | | static BOOL JPush_IsProduction = FALSE; |
| | | |
| | | @interface UniversalSDK : NSObject { |
| | | UIWebView* m_UIWebView; |
| | | UIButton* m_CloseBtn; |
| | | } |
| | | |
| | | -(void) HandleUnityMessage:(NSString*) json; |
| | | -(void) Init; |
| | | -(id) APNativeJSONObject:(NSData*) data; |
| | | -(NSData*) APNativeJSONData:(id) obj; |
| | | -(void) RemoveLocalNotificationWithIdentifierKey:(NSString*) idKey; |
| | | |
| | | -(void) JPushInit:(NSDictionary*)launchOptions; |
| | | |
| | | @end |
| | | |
| | | #endif |
New file |
| | |
| | | // |
| | | // UniversalSDK.m |
| | | // Unity-iPhone |
| | | // |
| | | // Created by 蔡瀚 on 2018/4/24. |
| | | // |
| | | |
| | | #import "UniversalSDK.h" |
| | | #import "JPUSHService.h" |
| | | #import "AdSupport/AdSupport.h" |
| | | #import "Tracking.h" |
| | | #import "opus.h" |
| | | #ifdef NSFoundationVersionNumber_iOS_9_x_Max |
| | | #import <UserNotifications/UserNotifications.h> |
| | | #endif |
| | | #import "SystemConfiguration/CaptiveNetwork.h" |
| | | #import <TTTracker/TTTracker+Game.h> |
| | | #import <AoyouSDK/AoyouSDK.h> |
| | | |
| | | @interface UniversalSDK()<JPUSHRegisterDelegate,UIWebViewDelegate> |
| | | @end |
| | | |
| | | @implementation UniversalSDK |
| | | |
| | | #define CHANNEL_NUM 1 |
| | | |
| | | static int s_frequency = 16000; |
| | | static int s_bitRate = 20000; |
| | | static int s_bandMode = OPUS_BANDWIDTH_WIDEBAND; |
| | | static int s_frameSize = 160; |
| | | static int sBatteryLevel = -1; |
| | | static int sBatteryState = -1; |
| | | static NSString* sAppID; |
| | | static NSString* sGameID; |
| | | static NSThread* _thread; |
| | | |
| | | -(void) Init |
| | | { |
| | | NSString *_bundlePath = [[NSBundle mainBundle] pathForResource:@"The2thWorldRES.bundle" ofType:nil]; |
| | | NSString* _configPath = [[NSBundle bundleWithPath:_bundlePath] pathForResource:@"The2thWorldSDKConfig" ofType:@"plist"]; |
| | | NSMutableDictionary *_configDict = [[NSMutableDictionary alloc] initWithContentsOfFile:_configPath]; |
| | | |
| | | UIDevice *_device = [UIDevice currentDevice]; |
| | | _device.batteryMonitoringEnabled = true; |
| | | |
| | | NSString* _uniqueID = [[NSUserDefaults standardUserDefaults] objectForKey:@"tsw_unique_id"]; |
| | | //获取IDFA |
| | | NSString* _idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; |
| | | |
| | | if(_uniqueID == NULL || [_uniqueID length] <= 0) |
| | | { |
| | | //判断IDFA是否为空 |
| | | BOOL isEmpty = [[_idfa stringByReplacingOccurrencesOfString:@"-" withString:@""] stringByReplacingOccurrencesOfString:@"0" withString:@""].length; |
| | | if (isEmpty) { |
| | | //不为空,将IDFA作为唯一标识 |
| | | _uniqueID = _idfa; |
| | | } |
| | | else { |
| | | //为空,获取UUID作为唯一标识 |
| | | _uniqueID = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; |
| | | } |
| | | |
| | | //保存唯一设备标识,如已存在则不进行任何处理 |
| | | [[NSUserDefaults standardUserDefaults] setObject:_uniqueID forKey:@"tsw_unique_id"]; |
| | | [[NSUserDefaults standardUserDefaults] synchronize]; |
| | | } |
| | | |
| | | // 取得UserAgent |
| | | UIWebView* _webView = [[UIWebView alloc] initWithFrame:CGRectZero]; |
| | | NSString* _userAgent = [_webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]; |
| | | |
| | | // 发送设备信息 |
| | | NSMutableDictionary *_dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: |
| | | _uniqueID,@"unique_id", |
| | | _idfa,@"android_id", |
| | | [NSNumber numberWithInt:S2U_DeviceInfo],@"code", |
| | | _userAgent,@"userAgent",nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | |
| | | // 发送个推id |
| | | [_dict removeAllObjects]; |
| | | [_dict setObject:[JPUSHService registrationID] forKey:@"clientID"]; |
| | | [_dict setObject:[NSNumber numberWithInt:S2U_PushClientID] forKey:@"code"]; |
| | | [self SendMessageToUnity:_dict]; |
| | | |
| | | // 热云初始化 |
| | | [Tracking initWithAppKey:_configDict[@"TrackingIO_AppKey"] |
| | | withChannelId:@"_default_"]; |
| | | |
| | | // 今日头条 |
| | | NSDictionary* _infoDictionary = [[NSBundle mainBundle] infoDictionary]; |
| | | [TTTracker startWithAppID:_configDict[@"TTTrack_AppID"] |
| | | channel:@"ios-snqxz" |
| | | appName:[_infoDictionary objectForKey:@"CFBundleDisplayName"]]; |
| | | |
| | | // 发送初始化完成 |
| | | [_dict removeAllObjects]; |
| | | [_dict setObject:[NSNumber numberWithInt:S2U_SdkInitComplete] forKey:@"code"]; |
| | | [_dict setObject:@"yl" forKey:@"channelPlatform"]; |
| | | [self SendMessageToUnity:_dict]; |
| | | } |
| | | |
| | | -(void)SendMessageToUnity:(NSDictionary*)dict |
| | | { |
| | | BOOL _result = [NSJSONSerialization isValidJSONObject:dict]; |
| | | if(_result) |
| | | { |
| | | NSData* _jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:NULL]; |
| | | UnitySendMessage(UNITY_OBJ_NAME, UNITY_FUNC_NAME, |
| | | [[[NSString alloc] initWithData:_jsonData encoding:NSUTF8StringEncoding] UTF8String]); |
| | | } |
| | | } |
| | | |
| | | -(void) BatteryThread { |
| | | while (TRUE) |
| | | { |
| | | [NSThread sleepForTimeInterval:1]; |
| | | |
| | | UIDevice *_device = [UIDevice currentDevice]; |
| | | |
| | | int _state = [_device batteryState]; |
| | | if(_state != sBatteryState){ |
| | | sBatteryState = _state; |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:sBatteryState], @"status", |
| | | [NSNumber numberWithInt:S2U_BatteryCharging], @"code", nil]; |
| | | |
| | | [self SendMessageToUnity:_dict]; |
| | | } |
| | | |
| | | int _level = (int)([_device batteryLevel] * 100); |
| | | if(_level != sBatteryLevel){ |
| | | sBatteryLevel = _level; |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:sBatteryLevel], @"level", |
| | | [NSNumber numberWithInt:S2U_BatteryLevel], @"code", nil]; |
| | | |
| | | [self SendMessageToUnity:_dict]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | -(void) OpenURL:(NSString*) url { |
| | | |
| | | if(m_UIWebView != NULL) { |
| | | [self btnClick:NULL]; |
| | | return; |
| | | } |
| | | |
| | | CGRect _bounds = UnityGetMainWindow().bounds; |
| | | |
| | | float _scale = _bounds.size.width / 1334; |
| | | |
| | | float _width = 982 * _scale; |
| | | float _height = 560 * _scale; |
| | | |
| | | float _offsetX = (_bounds.size.width - _width) * .5f; |
| | | float _offsetY = (_bounds.size.height - _height) * .5f; |
| | | |
| | | m_UIWebView = [[UIWebView alloc] initWithFrame:CGRectMake(_offsetX, _offsetY, _width, _height)]; |
| | | m_UIWebView.delegate = self; |
| | | m_UIWebView.scalesPageToFit = YES ; |
| | | m_UIWebView.scrollView.scrollEnabled = YES; |
| | | m_UIWebView.scrollView.bounces = NO; |
| | | NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:url]]; |
| | | [m_UIWebView loadRequest:request]; |
| | | } |
| | | |
| | | -(void) btnClick:(UIButton*)sender { |
| | | [m_CloseBtn removeFromSuperview]; |
| | | [m_CloseBtn removeTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; |
| | | m_CloseBtn = NULL; |
| | | |
| | | NSURLCache *_cache = [NSURLCache sharedURLCache]; |
| | | [_cache removeAllCachedResponses]; |
| | | [_cache setDiskCapacity:0]; |
| | | [_cache setMemoryCapacity:0]; |
| | | |
| | | [m_UIWebView removeFromSuperview]; |
| | | m_UIWebView = NULL; |
| | | } |
| | | |
| | | -(void)webViewDidStartLoad:(UIWebView *)webView{ |
| | | } |
| | | |
| | | -(void)webViewDidFinishLoad:(UIWebView *)webView{ |
| | | |
| | | [UnityGetMainWindow().rootViewController.view addSubview:m_UIWebView]; |
| | | CGRect _bounds = UnityGetMainWindow().bounds; |
| | | |
| | | float _scale = _bounds.size.width / 1334; |
| | | |
| | | float _width = 982 * _scale; |
| | | float _height = 560 * _scale; |
| | | |
| | | m_CloseBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; |
| | | [m_CloseBtn setFrame:CGRectMake(_width - 455 * _scale, _height - 86 * _scale, 180 * _scale, 72 * _scale)]; |
| | | [m_CloseBtn setTitle:@"我知道了" forState:UIControlStateNormal]; |
| | | |
| | | NSString *_bundlePath = [[NSBundle mainBundle] pathForResource:@"The2thWorldRES.bundle" ofType:nil]; |
| | | NSBundle *_bundle = [NSBundle bundleWithPath:_bundlePath]; |
| | | NSString *pic1Path = [_bundle pathForResource:@"TY_AN_34.png" ofType:nil]; |
| | | |
| | | [m_CloseBtn setBackgroundImage:[UIImage imageWithContentsOfFile:pic1Path] forState:UIControlStateNormal]; |
| | | [m_CloseBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; |
| | | [m_CloseBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; |
| | | |
| | | [m_UIWebView addSubview:m_CloseBtn]; |
| | | } |
| | | |
| | | -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ |
| | | } |
| | | |
| | | -(void)JPushInit:(NSDictionary*)launchOptions { |
| | | |
| | | |
| | | NSString *_bundlePath = [[NSBundle mainBundle] pathForResource:@"The2thWorldRES.bundle" ofType:nil]; |
| | | NSString* _configPath = [[NSBundle bundleWithPath:_bundlePath] pathForResource:@"The2thWorldSDKConfig" ofType:@"plist"]; |
| | | NSMutableDictionary *_configDict = [[NSMutableDictionary alloc] initWithContentsOfFile:_configPath]; |
| | | |
| | | JPUSHRegisterEntity *_entity = [[JPUSHRegisterEntity alloc] init]; |
| | | _entity.types = JPAuthorizationOptionAlert | JPAuthorizationOptionBadge | JPAuthorizationOptionSound; |
| | | if([[UIDevice currentDevice].systemVersion floatValue] > 8.0){ |
| | | } |
| | | |
| | | [JPUSHService registerForRemoteNotificationConfig:_entity |
| | | delegate:self]; |
| | | [JPUSHService setupWithOption:launchOptions |
| | | appKey:_configDict[@"JPush_AppKey"] |
| | | channel:@"develop" |
| | | apsForProduction:JPush_IsProduction |
| | | advertisingIdentifier:nil]; |
| | | } |
| | | |
| | | - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { |
| | | |
| | | NSDictionary * userInfo = response.notification.request.content.userInfo; |
| | | if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { |
| | | [JPUSHService handleRemoteNotification:userInfo]; |
| | | } |
| | | completionHandler(); |
| | | } |
| | | |
| | | - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler { |
| | | |
| | | NSDictionary * userInfo = notification.request.content.userInfo; |
| | | if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { |
| | | [JPUSHService handleRemoteNotification:userInfo]; |
| | | } |
| | | completionHandler(UNNotificationPresentationOptionAlert); |
| | | } |
| | | |
| | | -(id) APNativeJSONObject:(NSData *)data{ |
| | | if (!data) { |
| | | return nil; |
| | | } |
| | | |
| | | NSError *error = nil; |
| | | id retId = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; |
| | | |
| | | if (error) { |
| | | NSLog(@"%s trans data to obj with error: %@", __func__, error); |
| | | return nil; |
| | | } |
| | | |
| | | return retId; |
| | | } |
| | | |
| | | -(NSData *)APNativeJSONData:(id)obj { |
| | | NSError *error = nil; |
| | | NSData *data = [NSJSONSerialization dataWithJSONObject:obj options:0 error:&error]; |
| | | if (error) { |
| | | NSLog(@"%s trans obj to data with error: %@", __func__, error); |
| | | return nil; |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | -(void) RemoveLocalNotificationWithIdentifierKey:(NSString*) idKey{ |
| | | JPushNotificationIdentifier *identifier = [[JPushNotificationIdentifier alloc] init]; |
| | | identifier.identifiers = @[idKey]; |
| | | identifier.delivered = YES; //iOS10以上有效,等于YES则在通知中心显示的里面移除,等于NO则为在待推送的里面移除;iOS10以下无效 |
| | | [JPUSHService removeNotification:identifier]; |
| | | } |
| | | |
| | | -(void)HandleUnityMessage:(NSString *)json { |
| | | |
| | | NSLog(@"收到Unity发来的消息 => %@", json); |
| | | |
| | | NSData *_jsonData = [json dataUsingEncoding:NSUTF8StringEncoding]; |
| | | NSDictionary *_dict = [self APNativeJSONObject:_jsonData]; |
| | | |
| | | switch([[_dict objectForKey:@"code"] intValue]){ |
| | | case U2S_Init: |
| | | [self Init]; |
| | | sAppID = _dict[@"appID"]; |
| | | sGameID = _dict[@"gameID"]; |
| | | break; |
| | | case U2S_CopyContent: |
| | | [UIPasteboard generalPasteboard].string = _dict[@"content"]; |
| | | break; |
| | | case U2S_FreePlatformInit: |
| | | break; |
| | | case U2S_MakeKeyAndVisible: |
| | | { |
| | | UIWindow * _window = [[UIApplication sharedApplication].delegate window]; |
| | | if (_window != nil && _window.rootViewController != nil) { |
| | | [_window makeKeyAndVisible]; |
| | | } |
| | | } |
| | | break; |
| | | case U2S_OpenWebView: |
| | | [self OpenURL:_dict[@"url"]]; |
| | | break; |
| | | case U2S_FreePlatformLogin: |
| | | { |
| | | [AoyouSDK loadLoginingVCResultSuccess:^(NSString * _Nonnull loginTime, NSString * _Nonnull userName, NSString * _Nonnull sign) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSDictionary dictionaryWithObjectsAndKeys:sign, @"token", |
| | | [NSString stringWithFormat:@"%@",loginTime], @"token_expire", |
| | | userName, @"account", nil],@"info", |
| | | [NSNumber numberWithInt:S2U_FreePlatformLoginOk], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | } failed:^(NSInteger code, NSString * _Nonnull message) { |
| | | NSLog(@"登录失败: code=%zd, msg=%@",code,message); |
| | | }]; |
| | | } |
| | | break; |
| | | case U2S_FreePlatformLogout: |
| | | [AoyouSDK LoginOut]; |
| | | break; |
| | | case U2S_RoleLogin: |
| | | [AoyouSDK SetUserInfoWithRoleId:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]] |
| | | roleName:[_dict objectForKey:@"roleName"] |
| | | roleLevel:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]] |
| | | zoneId:[NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]] |
| | | zoneName:[_dict objectForKey:@"serverName"] |
| | | attach:@"" |
| | | block:^(NSInteger code) { |
| | | NSLog(@"---- code: %zd",code); |
| | | }]; |
| | | break; |
| | | case U2S_FreePlatformPay: |
| | | { |
| | | [AoyouSDK loadToFQVCWithRoleid:[_dict objectForKey:@"roleID"] |
| | | mo:[_dict objectForKey:@"mount"] |
| | | serverid:[_dict objectForKey:@"sid"] |
| | | productName:[_dict objectForKey:@"title"] |
| | | productDesc:[_dict objectForKey:@"title"] |
| | | attach:[NSString stringWithFormat:@"{\"appid\":\"%@\",\"cpinfo\":\"%@\",\"cporderid\":\"%@\",\"productid\":\"%@\"}", |
| | | sAppID, |
| | | [_dict objectForKey:@"cpInfo"], |
| | | [_dict objectForKey:@"orderId"], |
| | | sGameID] |
| | | productId:[_dict objectForKey:@"cpInfo"] |
| | | success:^(NSString * _Nonnull message, NSString * _Nonnull money) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:S2U_FreePlatformPayOk], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | } faild:^(NSString * _Nonnull message, NSInteger code, NSString * _Nonnull money) { |
| | | NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys: |
| | | [NSNumber numberWithInt:S2U_FreePlatformPayFail], @"code", nil]; |
| | | [self SendMessageToUnity:_dict]; |
| | | }]; |
| | | } |
| | | break; |
| | | case U2S_PayFinished: |
| | | break; |
| | | case U2S_BatteryListenStart: |
| | | if(_thread == NULL) |
| | | { |
| | | _thread = [[NSThread alloc] initWithTarget:self selector:@selector(BatteryThread) object:nil]; |
| | | [_thread setName:@"BatteryCheck"]; |
| | | } |
| | | if(![_thread isExecuting]) |
| | | { |
| | | [_thread start]; |
| | | } |
| | | break; |
| | | case U2S_BatteryListenStop: |
| | | |
| | | break; |
| | | case U2S_JPushRemoveLocalMessage: |
| | | [self RemoveLocalNotificationWithIdentifierKey:_dict[@"id"]]; |
| | | break; |
| | | case U2S_JPushAddLocalMessage: |
| | | { |
| | | JPushNotificationContent *_content = [[JPushNotificationContent alloc] init]; |
| | | if (_dict[@"title"]) { |
| | | _content.title = _dict[@"title"]; |
| | | } |
| | | if (_dict[@"subtitle"]) { |
| | | _content.subtitle = _dict[@"subtitle"]; |
| | | } |
| | | if (_dict[@"content"]) { |
| | | _content.body = _dict[@"content"]; |
| | | } |
| | | if (_dict[@"badge"]) { |
| | | _content.badge = @([_dict[@"badge"] intValue]); |
| | | } |
| | | if (_dict[@"action"]) { |
| | | _content.action = _dict[@"action"]; |
| | | } |
| | | if (_dict[@"extra"]) { |
| | | _content.userInfo = _dict[@"extra"]; |
| | | } |
| | | if (_dict[@"sound"]) { |
| | | _content.sound = _dict[@"sound"]; |
| | | } |
| | | JPushNotificationTrigger *_trigger = [[JPushNotificationTrigger alloc] init]; |
| | | if (_dict[@"fireTime"]) { |
| | | long _time = [_dict[@"fireTime"] longValue]; |
| | | NSNumber *date = @(_time); |
| | | if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) { |
| | | NSTimeInterval currentInterval = [[NSDate date] timeIntervalSince1970]; |
| | | NSTimeInterval interval = [date doubleValue] - currentInterval; |
| | | interval = interval > 0? interval : 0; |
| | | _trigger.timeInterval = interval; |
| | | } else { |
| | | _trigger.fireDate = [NSDate dateWithTimeIntervalSince1970: [date doubleValue]]; |
| | | } |
| | | JPushNotificationRequest *_request = [[JPushNotificationRequest alloc] init]; |
| | | _request.requestIdentifier = [NSString stringWithFormat:@"%@",_dict[@"id"]]; |
| | | _request.content = _content; |
| | | _request.trigger = _trigger; |
| | | _request.completionHandler = ^(id result) { |
| | | // iOS10以上成功则result为UNNotificationRequest对象,失败则result为nil;iOS10以下成功result为UILocalNotification对象,失败则result为nil |
| | | NSLog(@"结果返回:%@", result); |
| | | }; |
| | | [JPUSHService addNotification:_request]; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @end |
| | | |
| | | extern "C" void native_opus_init(int frequency, int bitRate, int bandMode) |
| | | { |
| | | s_frequency = frequency; |
| | | s_bandMode = bandMode; |
| | | s_bitRate = bitRate; |
| | | s_frameSize = frequency / 100; |
| | | } |
| | | |
| | | extern "C" int native_opus_encode(opus_int16 *pcm, int len, unsigned char *opus) |
| | | { |
| | | int errorCode = 0; |
| | | opus_int32 skip = 0; |
| | | OpusEncoder *enc = opus_encoder_create(s_frequency, CHANNEL_NUM, OPUS_APPLICATION_VOIP, &errorCode); |
| | | if (OPUS_OK != errorCode) { |
| | | enc = NULL; |
| | | return -1; |
| | | } |
| | | |
| | | opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(s_bandMode)); |
| | | opus_encoder_ctl(enc, OPUS_SET_BITRATE(s_bitRate)); |
| | | opus_encoder_ctl(enc, OPUS_SET_VBR(1)); |
| | | opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); |
| | | opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0)); |
| | | opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_SIGNAL_VOICE)); |
| | | opus_encoder_ctl(enc, OPUS_SET_DTX(0)); |
| | | opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(0)); |
| | | opus_encoder_ctl(enc, OPUS_GET_LOOKAHEAD(&skip)); |
| | | opus_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(16)); |
| | | |
| | | unsigned char *rbytes = opus; |
| | | opus_int16 *frame = pcm; |
| | | int totalSize = 0; |
| | | while (len >= s_frameSize) |
| | | { |
| | | opus_int32 length = opus_encode(enc, frame, s_frameSize, rbytes + sizeof(char), s_bitRate); |
| | | rbytes[0] = length; |
| | | frame += s_frameSize; |
| | | rbytes += length + sizeof(char); |
| | | len -= s_frameSize; |
| | | totalSize += length; |
| | | } |
| | | opus_encoder_destroy(enc); |
| | | return totalSize; |
| | | } |
| | | |
| | | extern "C" int native_opus_decode(unsigned char *opus, int len, short *pcm) |
| | | { |
| | | int err = 0; |
| | | //opus_int32 skip = 0; |
| | | |
| | | OpusDecoder *dec = opus_decoder_create(s_frequency, CHANNEL_NUM, &err); |
| | | if (err != OPUS_OK) { |
| | | dec = NULL; |
| | | return -1; |
| | | } |
| | | |
| | | while (len > 0) |
| | | { |
| | | int frame_opus_length = opus[0]; |
| | | int length = opus_decode(dec, opus + sizeof(char), frame_opus_length, pcm, s_frameSize, 0); |
| | | opus += sizeof(char) + frame_opus_length; |
| | | pcm += s_frameSize; |
| | | len = len - frame_opus_length - sizeof(char); |
| | | } |
| | | opus_decoder_destroy(dec); |
| | | return 0; |
| | | } |
New file |
| | |
| | | #include <stddef.h> |
| | | #include <stdlib.h> |
| | | |
| | | int* xlua_hotfix_flags = NULL; |
| | | int xlua_hotfix_flags_len = 0; |
| | | |
| | | extern "C" { |
| | | |
| | | int xlua_get_hotfix_flag(int idx) { |
| | | if (idx >= xlua_hotfix_flags_len) { |
| | | return 0; |
| | | } else { |
| | | return xlua_hotfix_flags[idx]; |
| | | } |
| | | } |
| | | |
| | | void xlua_set_hotfix_flag(int idx, int flag) { |
| | | int i = 0; |
| | | int* new_hotfix_flags = NULL; |
| | | if (idx >= xlua_hotfix_flags_len) { |
| | | if (xlua_hotfix_flags == NULL) { |
| | | xlua_hotfix_flags = (int*)malloc((idx + 1) * sizeof(int)); |
| | | } else { |
| | | new_hotfix_flags = (int*)realloc(xlua_hotfix_flags, (idx + 1) * sizeof(int)); |
| | | if (NULL == new_hotfix_flags) { // just skip operation |
| | | return; |
| | | } |
| | | xlua_hotfix_flags = new_hotfix_flags; |
| | | } |
| | | for(i = xlua_hotfix_flags_len; i < (idx + 1); i++) { |
| | | xlua_hotfix_flags[i] = 0; |
| | | } |
| | | xlua_hotfix_flags_len = idx + 1; |
| | | } |
| | | xlua_hotfix_flags[idx] = flag; |
| | | } |
| | | } |