pans
2016-12-15 87e3ee273b2f84081ac45926be9d8e5be3166eaa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "ccompressaudio.h"
 
#include <QMessageBox>
#include "publicfuc.h"
#include "DemoPublic.h"
 
CCompressAudio::CCompressAudio(QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);
 
    m_lUserID = -1;
    m_lChannel = -1;
 
    QStringList strings;
    strings<<"OggVorbis"<<"G711 ";
    ui.comboAudioType->addItems(strings);
 
    connect(ui.btnSave,  SIGNAL(clicked()), this, SLOT(clickSave()));
    connect(ui.btnRefresh,  SIGNAL(clicked()), this, SLOT(clickRefresh()));
}
 
CCompressAudio::~CCompressAudio()
{
 
}
 
//get CompressAudio info
int CCompressAudio::getCompressAudioInfo()
{
    NET_DVR_COMPRESSION_AUDIO  struCompressAudio;
    int iRet;
    DWORD uiRetParamsLen;
 
    iRet = NET_DVR_GetDVRConfig(m_lUserID, NET_DVR_GET_COMPRESSCFG_AUD, m_lChannel, &struCompressAudio, sizeof(NET_DVR_COMPRESSION_AUDIO), &uiRetParamsLen);
    if(iRet == 0)
    {
        //QMessageBox::information(this, tr("Please check!"), tr("Get Audio information unsuccessfully!"));
        KIT_DisplayErrorInfo("Get Audio information", KIT_ERRPR_DIS_TYPE);
        return HPR_ERROR;
    }
 
    ui.comboAudioType->setCurrentIndex(int(struCompressAudio.byAudioEncType));
 
    return HPR_OK;
}
 
//set CompressAudio info
int CCompressAudio::setCompressAudioInfo()
{
    NET_DVR_COMPRESSION_AUDIO  struCompressAudio;
    int iRet;
    DWORD uiRetParamsLen;
 
    iRet = NET_DVR_GetDVRConfig(m_lUserID, NET_DVR_GET_COMPRESSCFG_AUD, m_lChannel, &struCompressAudio, sizeof(NET_DVR_COMPRESSION_AUDIO), &uiRetParamsLen);
    if(iRet == 0)
    {
        QMessageBox::information(this, tr("Please check!"), tr("Get Audio information unsuccessfully!"));
        return HPR_ERROR;
    }
 
    struCompressAudio.byAudioEncType = ui.comboAudioType->currentIndex();
 
    iRet = NET_DVR_SetDVRConfig(m_lUserID, NET_DVR_SET_COMPRESSCFG_AUD, m_lChannel, &struCompressAudio, sizeof(NET_DVR_COMPRESSION_AUDIO));
    if(iRet == 0)
    {
        QMessageBox::information(this, tr("Please check!"), tr("Get Audio information unsuccessfully!"));
        return HPR_ERROR;
    }
 
    return HPR_OK;
}
 
void  CCompressAudio::clickSave()
{
    if(m_lUserID < 0)
    {
        return;
    }
    setCompressAudioInfo();
 
}
void  CCompressAudio::clickRefresh()
{
    if(m_lUserID < 0)
    {
        return;
    }
    getCompressAudioInfo();
 
}
 
void CCompressAudio::on_btnExit_clicked()
{
    close();
}
 
void CCompressAudio::showEvent ( QShowEvent * event )
{
    //disable warning
    if(event == NULL)
    {
    }
    if(m_lUserID < 0)
    {
        //QMessageBox::information(this, tr("Please login firstly!"), tr("Please login firstly!."));
        return;
    }
    else
    {
        getCompressAudioInfo();
    }
}
 
int CCompressAudio::setUserIDAndChannel(long lUserID, long lChannel)
{
    m_lUserID = lUserID;
    m_lChannel = lChannel;
 
    return HPR_OK;
}