//
//  XPSDKVideoConnection.h
//  
//
//  Created by Aleksandra Spirovska on 11/29/17.
//  Copyright © 2017 Milestone Systems A/S. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol XPSDKVideoConnectionDelegate;
@class XPSDKConnection;
/*!
 Video connection image stream method
 */
typedef enum {
    /*!
     Push mode - frames are pushed by the server over an established HTTP conection. High frame rate but the server may drop images quality
     */
    XPSDKVideoConnectionMethodPush,
    /*!
     Pull mode - frames are requested by the client in a sequence, each in separate HTTP request. Lower frame rate but higher quality of images
     */
    XPSDKVideoConnectionMethodPull
} XPSDKVideoConnectionMethod;


/*!
 Video ID - Currently a simple alias to NSString but defined as separet class for eventual future development (eg compare: methods or moving to GUIDs and etc
 */

typedef NSString *XPSDKVideoID;
typedef NSString *XPSDKViewID;

@interface XPSDKVideoConnection : NSObject {
    XPSDKVideoID videoID;
    XPSDKConnection *__weak metaConnection;
    BOOL finished;
    id <XPSDKVideoConnectionDelegate> __weak delegate;
}

@property (nonatomic, readonly) XPSDKVideoID videoID; /// Video ID of the video connection. Use that to send commands over the meta connection
@property (weak, nonatomic, readonly) XPSDKConnection * metaConnection; /// Each video connection keeps an instance of the main commands connection so it can send close and etc commands if needed and to update the network indicator
@property (nonatomic, readonly, getter=isOpened) BOOL opened; /// Set to YES if the video connection has been started
@property (nonatomic, weak) id<XPSDKVideoConnectionDelegate> delegate; /// Delegate of the video connection

@property (nonatomic, readonly) XPSDKVideoConnectionMethod method;


- (id) initFromControlConnection:(XPSDKConnection *) mainConnection
                         videoID:(XPSDKVideoID) vid;


// methods for instance variable 'finished'

/**
 Closes the connection to the video server
 Should be implemented by the subclasses
 */
- (void) close;
@end
