-
Notifications
You must be signed in to change notification settings - Fork 0
/
dvbcallsocket.cpp
119 lines (96 loc) · 3.1 KB
/
dvbcallsocket.cpp
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
/*
* Copyright (c) 2014 Amlogic, Inc. All rights reserved.
*
* This source code is subject to the terms and conditions defined in the
* file 'LICENSE' which is part of this source code package.
*
* Description: c++ file
*/
#define TAG "dvbcallsocket"
#include "am_av.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <android/log.h>
#include <systemcontrol/SystemControlClient.h>
#include "dvbcallsocket.h"
using namespace android;
#define LOGD(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
static sp<SystemControlClient> mSystemControl = NULL;
static void av_audio_callback(int event_type, AudioParms* param, void *user_data) {
LOGD("%s enter\n",__FUNCTION__);
switch ( event_type ) {
case AM_AV_EVT_AUDIO_CB:
/*
param->cmd;
param->param1;
param->param2;
*/
LOGD("%s: cmd: %d, param1: %d, param2: %d\n",__FUNCTION__, param->cmd, param->param1, param->param2);
if (mSystemControl != NULL) {
mSystemControl->setAudioParam(param->cmd, param->param1, param->param2);
} else {
LOGD("%s: binder systemcontrol service failed!\n", __FUNCTION__);
}
break;
}
}
#define ADEC_OPEN_DECODER 12
#define ADEC_CLOSE_DECODER 13
#define ADEC_SET_AUDIO_PATCH_MANAGE_MODE 26
int am_audio_open(int dev_no) {
LOGD("%s enter\n",__FUNCTION__);
if (mSystemControl == NULL) {
//mSystemControl = new SystemControlClient();
mSystemControl = SystemControlClient::getInstance();
AM_AV_SetAudioCallback(0,av_audio_callback,0);
LOGD("%s register av_audio_callback success!\n",__FUNCTION__);
AudioParms param;
if (mSystemControl != NULL) {
param.cmd = ADEC_SET_AUDIO_PATCH_MANAGE_MODE;
param.param1 = 0;
param.param2 = 1;
av_audio_callback(AM_AV_EVT_AUDIO_CB, ¶m, NULL);
LOGD("%s ADEC_SET_AUDIO_PATCH_MANAGE_MODE success!\n",__FUNCTION__);
}
return 0;
}
LOGD("%s SystemControlClient exsit!\n",__FUNCTION__);
return 1;
}
int am_audio_opendecoder(int dev_no) {
AudioParms param;
LOGD("%s enter\n",__FUNCTION__);
if (mSystemControl != NULL) {
param.cmd = ADEC_OPEN_DECODER;
param.param1 = 0;
param.param2 = 0;
av_audio_callback(AM_AV_EVT_AUDIO_CB, ¶m, NULL);
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
LOGD("%s SystemControlClient is not exsit!\n",__FUNCTION__);
return 1;
}
int am_audio_closedecoder(int dev_no) {
AudioParms param;
LOGD("%s enter\n",__FUNCTION__);
if (mSystemControl != NULL) {
param.cmd = ADEC_CLOSE_DECODER;
param.param1 = 0;
param.param2 = 0;
av_audio_callback(AM_AV_EVT_AUDIO_CB, ¶m, NULL);
LOGD("%s success!\n",__FUNCTION__);
return 0;
}
LOGD("%s SystemControlClient is not exsit!\n",__FUNCTION__);
return 1;
}
int am_audio_close(int dev_no) {
LOGD("%s enter\n",__FUNCTION__);
AM_AV_SetAudioCallback(0,NULL,NULL);
return 0;
}