diff --git a/Documents/P2P standard interface-Android.md b/Documents/P2P standard interface-Android.md new file mode 100644 index 0000000..6201748 --- /dev/null +++ b/Documents/P2P standard interface-Android.md @@ -0,0 +1,145 @@ +# P2P标准接口文档-iOS平台 + +## Concepts and usage 定义和用途 + +本文档定义了Android平台上P2P相关的接口标准,以及典型应用流程。 + +## Defination 定义 + +P2PModule: P2P模块,P2P所有功能在此模块内实现. + +## Interfaces 接口列表 + +#### Constructor 构造方法 +**P2PModule.create(Contect context, String appId, String appKey, String appSecretKey)** + +此接口用以完成P2P模块的创建,创建后即产生LiveController和VodController。为实现鉴权,需传入应用context以及appId,appKey,appSecretKey。 + +- context [Context] - Android应用上下文 +- appId [String] - 客户的应用Id +- appKey [String] - 客户的应用key +- appSecret [String] - 客户的应用secret + + +--- + + +#### Methods 方法 + +**P2PModule.getVersion()** + +获取SDK版本号。 + +- return [String] - SDK版本信息 + +**P2PModule.setEventHandler(Handler errorHandler)** + +设置事件处理函数,以处理P2PModule抛出的内部事件。事件标准参见“事件”一节。 + +- errorHandler [Handler] 事件处理函数 + +**LiveController.getInstance()** + +获取单例的直播下载模块。 + +- return LiveController - 直播下载模块 + +**LiveController.load(String liveUrl, OnLoadedListener listener)** + +启动一次直播下载。 + +- liveUrl [String] 直播url +- listener [OnLoadedListener] 回调函数,加载成功后会返回一个本地代理uri,播放器直接播放该uri即可 + +**LiveController.unload()** + +关闭一次直播下载,与load成对出现。 + +**VodController.getInstance()** + +获取单例的点播下载模块。 + +- return VodController - 点播下载模块 + +**VodController.load(String url, OnLoadedListener listener)** + +启动一次点播下载。 + +- url [String] 点播url +- listener [OnLoadedListener] 回调函数,加载成功后会返回一个本地代理uri,播放器直接播放该uri即可 + +**VodController.unload()** + +关闭一次点播下载,与load成对出现。 + +**VodController.pause()** + +暂停P2P模块下载,播放暂停时调用。 + +**VodController.resume()** + +恢复P2P模块下载,播放暂停后恢复播放时调用。 + +--- + +#### Events 事件 +| 事件 | 事件描述 | 建议处理措施 | +| :------------ | :------------ | :------------ | +| P2PModule.Error.AUTH_FAILED | P2P模块认证失败 | 检查是否传参错误 | +| P2PModule.Error.CHANNEL_INVALID | 直播频道不存在 | 回退至CDN播放 | +| P2PModule.Error.PLAY_FAILED | P2P播放失败 | 回退至CDN播放 | + +--- + +## Example 用例 + +```java +// Simple LiveVideoActivity +protected void onCreate(Bundle savedInstanceState) { + try { + LiveController.getInstance().load(liveUrl, new OnLoadedListener() { + @Override + public void onLoaded(Uri uri) { + mVideoPath = uri.toString(); + mVideoView.setVideoURI(uri); + mVideoView.start(); + } + + }); + } catch (Exception e) { + e.printStackTrace(); + } +} + +protected void onStop() { + mVideoView.stop(); + LiveController.getInstance().unload(); + // do something other... +} + +``` + +--- + +## Compatibility 兼容性 + +支持 Android 2.3 及以上版本 + +--- + +## See Also 相关资料 + +- [腾讯云X-P2P —— Android SDK开发指南](https://github.com/Vbytes/libp2pimpl-android/blob/master/README.md) + +--- + +## Contributors 贡献者 + +**Teams** + +![image](https://imgcache.qq.com/open_proj/proj_qcloud_v2/gateway/event/pc/tcc2017/css/img/logo1.png) | 腾讯云 +---|--- +![image](https://i.h2.pdim.gs/b2a97149ec43dfc95eb177508af29f6c.png) | 熊猫直播 + +**Individuals** +- \ No newline at end of file diff --git a/Documents/P2P standard interface-Flash.md b/Documents/P2P standard interface-Flash.md new file mode 100644 index 0000000..cadac45 --- /dev/null +++ b/Documents/P2P standard interface-Flash.md @@ -0,0 +1,98 @@ +# P2P标准接口文档-Flash平台 + +## Concepts and usage 定义和用途 + +本文档定义了Flash平台上P2P相关的接口标准,以及典型应用流程。 + +## Defination 定义 + +P2PNetStream: 基于Flash标准NetStream派生出的P2P NetStream. + +## Interfaces 接口列表 + +#### Constructor 构造方法 +Flash SDK采取远程加载的方式调用,加载成功后即可获取P2PNetStream +```actionscript + var loader:Loader = new Loader(); + loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void { + var P2PNetStream:NetStream = e.currentTarget.content.stream; + }); + loader.load(new URLRequest(sdkUrl)); +``` +- sdkUrl [String] - SDK远程加载url + +--- + + +#### Methods 方法 +P2PNetStream继承自flash.net.NetStream,支持NetStream的所有原生方法。 + +**NetStream.play(videoUrl, config)** + +播放函数,调用后及可启动下载及播放 +- videoUrl [String] - 直播、点播url,支持rtmp/flv/mp4/HLS; +- config [Object] - 配置信息,用以配置SDK参数。预留使用,不传则使用默认值。 + +**其他方法** + +其他方法参见[flash.net.NetStream说明文档](http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html) + +--- + +#### Events 事件 +| 事件 | 事件描述 | 建议处理措施 | +| :------------ | :------------ | :------------ | +| **NetStream.Play.Failed** | P2P播放失败 | 回退至CDN播放 | + +--- + +## Example 用例 + +``` + public class LiveDemo extends Sprite { + private var _P2PNetStream:NetStream = null; + + public function LiveDemo() { + private var _video:Video = new Video(640, 480); + addChild(_video); + stage.scaleMode = StageScaleMode.NO_SCALE; + var loadSuccess:Function = function(e:Event):void { + _P2PNetStream = e.currentTarget.contentsdk.stream; + _P2PNetStream.addEventListener(NetStatusEvent.NET_STATUS, onPlayStatus); + _P2PNetStream.play("http://live.qcloud.com/test.flv?sign=f767172ee97231f8bd1d2fbf8c38bbdc&t=59196bda"); + _video.attachNetStream(_P2PNetStream); + } + var loader:Loader = new Loader(); + loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadSuccess); + loader.load(new URLRequest("http://img.qcloud.com/open/qcloud/video/sdk/flash/superp2p.swf")); + } + + private function onPlayStatus(e:NetStatusEvent):void { + if(e.info.code == "NetStream.Play.Failed") { + // p2p播放失败,请在此进行播放回退等处理 + } + } + } +``` +--- + +## Compatibility 兼容性 +支持 flash player 10.1 及以上版本 + +--- +## See Also 相关资料 +- [flash.net.NetStream](http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html) +- [腾讯云p2p直播服务 —— Web SDK开发指南](https://github.com/Vbytes/flash-demo/blob/master/README.md) +--- + +## Contributors 贡献者 + +**Teams** + +![image](https://i.h2.pdim.gs/b2a97149ec43dfc95eb177508af29f6c.png) | 熊猫直播 +---|--- +![image](https://imgcache.qq.com/open_proj/proj_qcloud_v2/gateway/event/pc/tcc2017/css/img/logo1.png) | 腾讯云 + + +**Individuals** +- diff --git a/Documents/P2P standard interface-iOS.md b/Documents/P2P standard interface-iOS.md new file mode 100644 index 0000000..82f73a4 --- /dev/null +++ b/Documents/P2P standard interface-iOS.md @@ -0,0 +1,153 @@ + +# P2P标准接口文档-iOS平台 + +## Concepts and usage 定义和用途 + +本文档定义了iOS平台上P2P相关的接口标准,以及典型应用流程。 + +## Defination 定义 + +P2PModule: P2P模块,P2P所有功能在此模块内实现. + +## Interfaces 接口列表 + +#### Constructor 构造方法 +**P2PModule.init:(NSString *)appId appKey:(NSString *)appKey appSecretKey:(NSString *)appSecretKey** + +此接口用以完成P2P模块的创建。为实现鉴权,需传入appId,appKey,appSecretKey。 + +- appId [String] - 客户的应用Id +- appKey [String] - 客户的应用key +- appSecret [String] - 客户的应用secret + +**P2PModule.release** + +析构方法,释放P2P模块。 + +--- + +#### Methods 方法 + +**P2PModule.getVersion** + +获取SDK版本号。 + +- return [NSString] - SDK版本信息 + +**P2PModule.setDelegate: (id) aDelegate** + +设置事件处理函数,以处理P2PModule抛出的内部事件。事件标准参见“事件”一节。 + +- aDelegate [id] 事件处理协议 + +**P2PModule.load: (NSString *)liveUrl listener:(void(^)(NSURL*))listener** + +启动一次直播下载。 + +- liveUrl [String] 直播url +- listener [listener] 回调函数,加载成功后会返回一个本地代理uri,播放器直接播放该uri即可 + +**LiveController.unload** + +关闭一次直播下载,与load成对出现。 + +**VodController.load: String url, listener:(void(^)(NSURL*))listener** + +启动一次点播下载。 + +- url [String] 点播url +- listener [listener] 回调函数,加载成功后会返回一个本地代理uri,播放器直接播放该uri即可 + +**VodController.unload** + +关闭一次点播下载,与load成对出现。 + +**VodController.pause** + +暂停P2P模块下载,播放暂停时调用。 + +**VodController.resume** + +恢复P2P模块下载,播放暂停后恢复播放时调用。 + +--- + +#### Events 事件 +| 事件 | 事件描述 | 建议处理措施 | +| :------------ | :------------ | :------------ | +| P2PModule.Error.AUTH_FAILED | P2P模块认证失败 | 检查是否传参错误 | +| P2PModule.Error.CHANNEL_INVALID | 直播频道不存在 | 回退至CDN播放 | +| P2PModule.Error.PLAY_FAILED | P2P播放失败 | 回退至CDN播放 | + +--- + +## Example 用例 + +```Objective-c + // Example: 应用的入口AppDelegate.m + #import + + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + ... + [P2PModule init:appID appKey:key appSecretKey:secret]; + ... + } + + - (void)applicationWillTerminate:(UIApplication *)application { + ... + // 释放P2P模块 + [VPModule release]; + ... + } + +``` + +```Objective-c + // Example: LiveVideoController.m + + #import + #import + + - (void)viewDidLoad { + [super viewDidLoad]; + + [P2PLiveController load:[liveUrl absoluteString] listener:^(NSURL *url){ + if (url != nil) { + // start to play proxy url + [self.player prepareToPlay:[url absoluteString]]; + } + }]; + } + + - (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + [self.player shutdown]; + + [P2PLiveController unload]; + } +``` + + +--- + +## Compatibility 兼容性 + + +--- + +## See Also 相关资料 + +- [腾讯云X-P2P —— iOS SDK开发指南](https://github.com/Vbytes/ios-sample/blob/master/README.md) + +--- + +## Contributors 贡献者 + +**Teams** + +![image](https://imgcache.qq.com/open_proj/proj_qcloud_v2/gateway/event/pc/tcc2017/css/img/logo1.png) | 腾讯云 +---|--- +![image](https://i.h2.pdim.gs/b2a97149ec43dfc95eb177508af29f6c.png) | 熊猫直播 + +**Individuals** +- \ No newline at end of file diff --git "a/images/TIM\345\233\276\347\211\20720170926221053.jpg" "b/images/TIM\345\233\276\347\211\20720170926221053.jpg" new file mode 100644 index 0000000..a349980 Binary files /dev/null and "b/images/TIM\345\233\276\347\211\20720170926221053.jpg" differ diff --git a/images/qcloud_logo2017.png b/images/qcloud_logo2017.png new file mode 100644 index 0000000..996ecae Binary files /dev/null and b/images/qcloud_logo2017.png differ