Latest 0.1.4
Homepage https://github.com/ldsappopensdk/LDSAppOpenSDK
License MIT
Platforms ios 9.0, requires ARC
Dependencies AFNetworking, MQTTClient/Websocket, CocoaAsyncSocket, CocoaLumberjack
Frameworks AVFoundation, AudioToolbox, VideoToolbox, CoreMedia
Authors ,

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

LDSAppOpenSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'LDSAppOpenSDK'

Author

[email protected], [email protected]

License

LDSAppOpenSDK is available under the MIT license. See the LICENSE file for more info.

iOS SDK interface instructions

Special Note 1: This SDK only includes the function of real machine debugging, and does not support the debugging of any simulator.

Special Note 2: The functions provided by this SDK have been explained in the document. Any function not described in the document is not supported, and the user can ask us to improve the function.

Introduction

This document is used to explain the relationship between the LDS open platform SDK iOS version interface and the order of the interface call. The interfaces of the open platform SDK iOS version are described in detail.

Demo Config

close bitcode

CI Status

Fast Sample

1.get video list

+ (void) _getDevListWithCallback:(void (^_Nonnull)(NSArray<LDSDeviceInfo*>* _Nullable list,int totalCount, NSError* _Nullable error))callback;

Description: By calling _getDevListWithCallback, you can get a list (Array ofLDSDeviceInfo objects), each item containing a camera information. Developers can display lists through UITableView.

The interface is located on the LDSAppOpenSDK.h 51 line.

The sample Demo code is CameraListViewController

2.add Device

Note: When you need to add a device, you can click the plus sign (+) in interface 1 to enter interface 2,

Step1:

Step2:

Enter the wifiname and password to make the camera connect the Internet.

Step3:

Turn to Set Wifi page and select the Camera wifi(LDS_IPC_XXX) then turn to this page

Step4:

wait camera bind to server

/**
 add device
 @param ssid name of wifi
 @param psw password of wifi
 @param callback callback
 */
+ (void) startAddDeviceWifi:(NSString *_Nonnull)ssid andPassword:(NSString *_Nonnull)psw
callback:(void (^_Nonnull)(BIND_DEVICE_STATE result))callback;

callback will return the bind status and result

typedef enum : NSUInteger {
    BIND_STATE_UNKOWN = 0,//not start bind or just start bind
    BIND_STATE_SSIDERROR = 2,//ssid is not "IPC_XXX"
    BIND_STATE_DICOVERDEVIC_SUCCESS = 100,//disover device success
    BIND_STATE_SENDUSERINFO_SUCCESS = 110,//discover device failed
    BIND_STATE_DICOVERDEVIC_TIMEOUT = 200,//send userinfo to device success
    BIND_STATE_SENDUSERINFO_TIMEOUT = 120, //send userinfo to device failed
    BIND_STATE_SENDWIFIINFO_SUCCESS = 111, //send wifiinfo to device failed
    BIND_STATE_SENDWIFIINFO_TIMEOUT = 112, //send wifiinfo to device failed
    BIND_STATE_FORMATE_RROR = 1001,//uid or devid error
    BIND_STATE_SUCCESS = 1000,//bind to cloud device success
    BIND_STATE_TIMEOUT = 1002,//bind to cloud device failed
    BIND_STATE_BIDING = 1003,//is binding
} BIND_DEVICE_STATE;

At this point, a simple device addition is complete.

The interface code is located on LDSAppOpenSDK and line 60
Sample Demo code BindturntoWifiViewController

3.live preview

See the CameraLiveViewController for the code to preview the video.

self.xplayer = [LDSAppOpenSDK createPlayerWithDeviceSerial:_deviceId andType:LDSXplayerLiveType];
self.xplayer.delegate = self;
[self.xplayer setPlayerView:self.playerView];
[self.xplayer startRealPlay];

Code description:

1, create an LDSXplayer object requires a DeviceSerial id, the camera’s unique id, this cameraId can be obtained from the LDSDeviceInfo object

2, you need to implement the LDSPlayerDelegatemethod:

@protocol LDSPlayerDelegate <NSObject>

- (void)playerEventNotify:(LDSXplayer *)player didReceviedCode:(LDSErrorCode)errorCode adidPlayFailed:(NSError *)error;

- (void)playerEventNotify:(LDSXplayer *)player didReceviedCode:(LDSMessageCode )messageCode andMsg:(NSDictionary *)message;

@end

At this point, the preview function is basically completed.

4.Camera playback

For the code of the playback function, please refer to the CloudPlayBackViewController file. The main core functions are:


//Query Camera cloud storage video
+ (void)queryCloudRecord:(NSString *)deviceSerial
            andStartTime:(NSString *)startTime
              andEndTime:(NSString *)endTime
              andPageNum:(NSInteger )pageNum
             andPageSize:(NSInteger )pageSize
                callback:(void (^)(NSDictionary * _Nullable, NSError * _Nullable))callback

Start playback playback (requires 2 steps)

  1. first build theLDSXplayer object
self.xplayer = [LDSAppOpenSDK createPlayerWithDeviceSerial:_devId andType:LDSXplayerCloudRecordType];
self.xplayer.delegate = self;
[self.xplayer setPlayerView:self.playerView];

Code Description: Building EZPlayer on line 37 ofCloudPlayBackViewController

  1. Start playback playback (cloud storage):
weakSelf.pullList = dic[@"data"][@"list"];//queryCloudRecord callback dic
[self.xplayer startPlayback:_pullList];

Code Description: playback Pull and start on line 79 ~ 111 of CloudPlayBackViewController

5.SDK INIT

#define kLDSAppOpenSDKKey @"appa070"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [LDSAppOpenSDK initLibWithAppKey:kLDSAppOpenSDKKey];
    return YES;
}

Description: The SDK is initialized when the program starts, and AppKey needs to be set during initialization.

6.Logging in to the relevant interface

//HTTPRequest 

+ (void) loginWithUserName:(NSString *_Nonnull)username passwd:(NSString *_Nonnull)passwd callback:(void (^_Nonnull)(NSDictionary * _Nullable response, NSError * _Nullable error))callback;

+ (void) setHeader:(NSDictionary *_Nonnull)header;

+ (void) reqUserAuthInfoWithCallback:(void (^_Nonnull)(NSDictionary * _Nullable response, NSError * _Nullable error))callback;

//LDSAppOpenSDK line 42
+ (void) setAuthInfo:(LDSAuthInfo *_Nonnull)authInfo;

Interface Description:

The first step is to use the +(void) loginWithUserName:(NSString *_Nonnull)username passwd:(NSString *_Nonnull)passwd callback: method to get the token object accessToken;

In the second step, the obtained AccessToken string is set to the SDK by the +(void) setHeader: method;

In the third step, the user can use +(void) reqUserAuthInfoWithCallback:.to get user AuthInfo

then save authinfo to LDSAppOpenSDK

7.Device related interface

1.WiFi configuration

/**
 add device

 @param ssid name of wifi
 @param psw password of wifi
 @param callback callback
 */
+ (void) startAddDeviceWifi:(NSString *_Nonnull)ssid
             andPassword:(NSString *_Nonnull)psw
                   callback:(void (^_Nonnull)(BIND_DEVICE_STATE result))callback;

Interface Description:

WiFi configuration note: A brand new device, the query result must be the device does not exist when the serial number query. Be sure to reset the device before the second and subsequent WiFi configuration, and then configure the wifi.

2.Playback related interface

/**
 *  start cloud remote play,async api,return operation success,not play success
 *
 *  @param deviceSerial cloud deviceSerial
 *
 *  @param startTime cloud file startTime
 *
 *  @param endTime cloud file endTime
 *
 *  @param pageNum cloud file pageNum [1~N]
 *
 *  @param pageSize onepage return Size
 *
 *  @param callback NSDictionary dic[@"data"][@"list"]   NSError *error
 */
+ (void)queryCloudRecord:(NSString *)deviceSerial
            andStartTime:(NSString *)startTime
              andEndTime:(NSString *)endTime
              andPageNum:(NSInteger )pageNum
             andPageSize:(NSInteger )pageSize
                callback:(void (^)(NSDictionary * _Nullable, NSError * _Nullable))callback;

8.LDSXplayer related interface

/**
 *  set LDSXplayer deviceSerial
 *
 *  @param deviceSerial   device Serial
 *
 *  @param type   LDSplay type
 */
+ (instancetype)createPlayerWithDeviceSerial:(NSString *)deviceSerial andType:(LDSXplayerType)type;

/**
 *  set LDSXplayer view
 *
 *  @param view  show view Frame
 *
 */
- (void)setPlayerView:(UIView *)view;

/**
 *  release LDSXplayer
 *
 */
- (void)releasePlayer;

Interface Description: After constructing LDSXplayer, you must set the view object carried by the player, otherwise there will be no playback screen.

1.preview interface

/**
 *  start play,async api,
 *
 */
- (void)startRealPlay;

/**
 *  stop play,async api,
 */
- (void)stopRealPlay;

Note: Remember to stopRealPlay after startRealPlay, to ensure that the methods appear in pairs, otherwise it is prone to problems.

2.Set video resolution


/**
 *  change video resolution 
 *
 *  @param quality LDSVideoQuality
 */
- (void)selectResoultion:(LDSVideoQuality)quality;

3.sound switch

/**
 *  mute yes close sound
 *
 *  @param mute yes/no
 */
- (void)mute:(BOOL)mute;

Interface Description: The switch sound is only valid after starting playback.

4. Voice Intercom (currently only supports half-duplex intercom)


/**
 *  start talk,async api,
 *
 */
- (void)startVoiceTalk;

/**
 *  stop talk,async api,
 *
 */
- (void)stopVoiceTalk;

Note: When you startVoiceTalk, remember to stopVoiceTalk, to ensure that the methods are paired, otherwise it is easy to have problems; if you leave the page, releasePlayer does not need to call stopVoiceTalk.

5.CaptureImage

/**
 *  capture live picture 
 *
 *  @return image
 */
- (UIImage *)captureImage;

The image interface directly gets the UIImage object. your can save or show it

Playback Play

Playback interface


/**
 *  start remote play
 */
- (void)startPlayback:(NSArray*)timelist;

typedef NS_ENUM(NSInteger, LDSPlaybackControl) {
    LDS_PLAYBACK_CONTROL_PAUSE = 1,         // pause
    LDS_PLAYBACK_CONTROL_RESUME=2,           // resume
};
/**
 *  remote playback control
 *
 *  @param controlCode LDSPlaybackControl
 */
- (void)playControl:(LDSPlaybackControl)controlCode;

/**
 *  stop remote play
 */
- (void)stopPlayback;

LDSPlayerDelegate interface

@protocol LDSPlayerDelegate <NSObject>

@optional
/**
 *  LDSPlayer  play failed error callback
 *
 *  @param player LDSPlayer object
 *  @param error  LDSPlayer error
 */
- (void)playerEventNotify:(LDSXplayer *)player didReceviedCode:(LDSErrorCode)errorCode adidPlayFailed:(NSError *)error;

/**
 *  LDSPlayer play message callback
 *
 *  @param player      LDSPlayer object
 *  @param messageCode LDSPlayer messageCode
 */
- (void)playerEventNotify:(LDSXplayer *)player didReceviedCode:(LDSMessageCode )messageCode andMsg:(NSDictionary *)message;

@end

Interface Description:

playerEventNotify: callback some state of the player;

Error callback: The player fails to play, and the user can judge the occurrence of the error based on the error code.

LDSXplayer enumeration value

typedef NS_ENUM(NSInteger, LDSXplayerType) {
    LDSXplayerLiveType  = 0,           //live
    LDSXplayerCloudRecordType   = 1,   //cloud
    LDSXplayerDeviceRecordType  = 2    //device
};

/* live videoQuailty */
typedef NS_ENUM(NSInteger, LDSVideoQuality) {
    LDSVideoQualityHigh   = 0x01,   //high
    LDSVideoQualityLow    = 0x05,  //low
};

/* Player LDSPlayer state message define */
typedef NS_ENUM(NSInteger, LDSMessageCode) {
    PLAYER_REALPLAY_START = 20001,        //live start
    PLAYER_REALPLAY_START_SUCCESS  = 20002,     //live start success
    PLAYER_REALPLAY_STOP = 20003 ,        //live stop
    PLAYER_REALPLAY_STOP_SUCCESS  = 20004,     //live stop success
    PLAYER_SET_VIDEOLEVEL = 20005,     //live videoQuailty change
    PLAYER_SET_VIDEOLEVEL_SUCCESS = 20006, //live videoQuailty change
    PLAYER_GET_VIDEOLEVEL = 20007,     //live videoQuailty change
    PLAYER_GET_VIDEOLEVEL_SUCCESS = 20008, //live videoQuailty change
    PLAYER_STREAM_RECONNECT = 20009,      //live reconnect
    PLAYER_VOICE_TALK_START = 20010,      //live talk start
    PLAYER_VOICE_TALK_START_SUCCESS = 20011 ,      //live talk start
    PLAYER_VOICE_TALK_STOP= 20012,        //live talk stop
    PLAYER_VOICE_TALK_STOP_SUCCESS = 20013,//live talk stop success
    PLAYER_WIDTH_AND_HEIGHT_INFO= 20014,        //player width and height
    PLAYER_PLAYBACK_START = 20015,       //record playback start
    PLAYER_PLAYBACK_TIMESTAMP = 20016 ,   //record playback start
    PLAYER_PLAYBACK_STOP= 20017 ,        //record playback stop
    PLAYER_PLAYBACK_RESUME= 20018,    //record stop by user
    PLAYER_PLAYBACK_PAUSE= 20019,       //record palyback pause
    PLAYER_REALPLAY_STREAM_SPEED  = 20020,     //live stream speed
};

/* Player LDSErrorCode state message define */
typedef NS_ENUM(NSInteger, LDSErrorCode) {
    PLAYER_CREATE_PLAYER_ERROR = 30001,     //player setplayerView error
    PLAYER_SET_PLAYERVIEW_ERROR = 30002 ,          //player setplayerView error
    PLAYER_START_REALPLAY_ERROR  = 30003,          //player live start error
    PLAYER_STOP_REALPLAY_ERROR = 30004,            //player live realplay stop error
    PLAYER_RELEASE_REALPLAY_ERROR = 30005,         //player realplay release error
    PLAYER_START_VOICE_TALK_ERROR = 30006,         //player live talk start error
    PLAYER_STOP_VOICE_TALK_ERROR = 30007,          //player live talk stop error
    PLAYER_CAPATURE_IMAGE_ERROR = 30008,           //player record capature error
    PLAYER_MUTE_ERROR= 30009 ,                     //player record mute error
    PLAYER_CHANGE_VIDEORESOULTION_ERROR = 30010,   //live Resoultion change error
    PLAYER_START_LOCALRECORD_ERROR= 30011 ,        //player record localRecord start error
    PLAYER_STOP_LOCALRECORD_ERROR= 30012 ,         //player record localRecord stop error
    PLAYER_PLAY_CLOUD_RECORD_ERROR = 30013,        //player cloud record play error
    PLAYER_PLAY_DEVICE_RECORD_ERROR = 30014,       //player device record play error
    PLAYER_START_PLAYBACK_ERROR= 30015 ,           //player record playback start error
    PLAYER_STOP_PLAYBACK_ERROR = 30016,            //player record playback stop error
    PLAYER_PAUSE_PLAYBACK_ERROR= 30017  ,              //player pause error
    PLAYER_RESUME_PLAYBACK_ERROR = 30018 ,             //player resume error
};

typedef NS_ENUM(NSInteger, LDSPlaybackControl) {
    LDS_PLAYBACK_CONTROL_PAUSE = 1,         // pause
    LDS_PLAYBACK_CONTROL_RESUME=2,           // resume
};

Latest podspec

{
    "name": "LDSAppOpenSDK",
    "version": "0.1.4",
    "summary": "A SDK for leedarson app",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/ldsappopensdk/LDSAppOpenSDK",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "asomeliao",
        "[email protected]  ": "yyb"
    },
    "source": {
        "git": "https://github.com/ldsappopensdk/LDSAppOpenSDK.git",
        "tag": "0.1.4"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "frameworks": [
        "AVFoundation",
        "AudioToolbox",
        "VideoToolbox",
        "CoreMedia"
    ],
    "source_files": "LDSAppOpenSDK/Vendors/**/*{.h,.m}",
    "dependencies": {
        "AFNetworking": [],
        "MQTTClient/Websocket": [],
        "CocoaAsyncSocket": [],
        "CocoaLumberjack": []
    },
    "libraries": [
        "z.1.2.5",
        "bz2.1.0",
        "iconv.2.4.0",
        "stdc++"
    ],
    "pod_target_xcconfig": {
        "CLANG_CXX_LANGUAGE_STANDARD": "gnu++14",
        "CLANG_CXX_LIBRARY": "libc++",
        "ENABLE_BITCODE": "NO"
    },
    "vendored_frameworks": "LDSAppOpenSDK/Vendors/LDSAppOpenSDK.framework"
}

Pin It on Pinterest

Share This