//
//  PSGlobalStatus.h
//  PSGlobalStatus
//
//  Created by sjdd on 6/28/16.
//  Copyright © 2016 sjdd. All rights reserved.
//

#ifndef _LIB_PS_GLOBAL_STATUS_H_
#define _LIB_PS_GLOBAL_STATUS_H_

#include <pthread.h>

#define PSPULL_STATUS_STOP      0
#define PSPULL_STATUS_REQUEST   2
#define PSPULL_STATUS_WAIT      4
#define PSPULL_STATUS_START     6
#define PSPULL_STATUS_PROBE     8
#define PSPULL_STATUS_PROBEOK   10
#define PSPULL_STATUS_RUN       100

#define MAX_PS_PULL_NUMBER 9

class PSPullStatus;
class PSPushStatus;

class PSGlobalStatus
{
public:
    static PSGlobalStatus *GetInstance() {
        if (!m_pInstance) {
            m_pInstance = new PSGlobalStatus;
        }
        
        return m_pInstance;
    }
    
    virtual void destructor();
    
    // mutex
    pthread_mutex_t mutex;
    
    // Pull Status
    int pull_number;
    PSPullStatus *pull_status[MAX_PS_PULL_NUMBER];
    
    // Push Status
    PSPushStatus *push_status;
    
private:
    PSGlobalStatus();
    PSGlobalStatus(PSGlobalStatus const &);
    PSGlobalStatus & operator=(PSGlobalStatus const &);
    ~PSGlobalStatus();
    
    static PSGlobalStatus *m_pInstance;
};

class PSPullStatus {
    
public:
    PSPullStatus();
    ~PSPullStatus();
    
    void *psdemux;
    int stream_id;
    
    char pull_url[2048];
    char pull_cdn_ip[64];
    
    int pull_protocol;
    int pull_status;
    int pull_cbuffer;
    int pull_freeze;
    
    long long pull_start_time;
    
};

class PSPushStatus {
    
public:
    PSPushStatus();
    ~PSPushStatus();
    
    char push_url[2048];
    char push_cdn_ip[64];
    
    int push_protocol;
    int push_status;
    int push_cbuffer;
    int push_freeze;
    
    long long push_start_time;
    
};

#endif // _LIB_PS_GLOBAL_STATUS_H_
