Ver Fonte

实现所有IO处理逻辑

Yu.Ding há 2 dias atrás
pai
commit
b6d55bf752

+ 5 - 14
Modules/onvif/test-onvif-backchannel.c

@@ -22,7 +22,7 @@
 
 #include <string.h>
 #include <stdio.h>
-#include "iniparser.h"
+#include "iniparser/iniparser.h"
 
 #define CONF "/oem/etc/config.xml"
 #define SPK_CONF    "/etc/speaker.conf"
@@ -94,7 +94,7 @@ main (int argc, char *argv[])
 	  return -1;
   }
 
-  //putenv("GST_DEBUG=4");
+  // putenv("GST_DEBUG=4");
   gst_init (&argc, &argv);
 
   optctx = g_option_context_new (NULL);
@@ -123,17 +123,8 @@ main (int argc, char *argv[])
    * element with pay%d names will be a stream */
   factory = gst_rtsp_onvif_media_factory_new ();
   //! video/x-raw, format=(string)RGB, width=(int)640, height=(int)480
-  if(strcmp(conf.dev_type, "Ei-V05") == 0 || strcmp(conf.dev_type, "SQ10-C") == 0 || strcmp(conf.dev_type, "SQ10-V") == 0)
-  {
-    if(strcmp(conf.media_stream, "main") == 0)
-      strcpy(launchstr, "( rtspsrc protocols=tcp latency=100 user-agent='Zycoo rtsp client' location=rtsp://10.231.132.139:554/stream1 ! rtph264depay name=d d. ! queue ! rtph264pay config-interval=1 pt=96 name=pay0 ");
-    else if(strcmp(conf.media_stream, "sub") == 0)
-      strcpy(launchstr, "( rtspsrc protocols=tcp latency=100 user-agent='Zycoo rtsp client' location=rtsp://10.231.132.139:554/stream2 ! rtph264depay name=d d. ! queue ! rtph264pay config-interval=1 pt=96 name=pay0 ");
-  }
-  else
-  {
-    strcpy(launchstr, "( filesrc loop=true location=\"/usr/share/onvif/speaker.h264\" ! video/x-h264 ! h264parse ! rtph264pay pt=96 config-interval=5 name=pay0 ");
-  }
+ 
+  strcpy(launchstr, "( filesrc loop=true location=\"/usr/share/onvif/speaker.h264\" ! video/x-h264 ! h264parse ! rtph264pay pt=96 config-interval=5 name=pay0 ");
 
   if(strcmp(conf.enable_mic, "yes") == 0)
   {
@@ -147,7 +138,7 @@ main (int argc, char *argv[])
   
   gst_rtsp_onvif_media_factory_set_backchannel_launch
       (GST_RTSP_ONVIF_MEDIA_FACTORY (factory),
-      "( capsfilter caps=\"application/x-rtp, media=audio, payload=0, clock-rate=8000, encoding-name=PCMU, channels=1\" name=depay_backchannel ! rtppcmudepay ! mulawdec ! identity drop-probability=0.01 sync=true ! audioconvert ! audioresample ! alsasink async=false sync=false )");
+      "( capsfilter caps=\"application/x-rtp, media=audio, payload=0, clock-rate=8000, encoding-name=PCMU, channels=1\" name=depay_backchannel ! rtppcmudepay ! mulawdec ! audioconvert ! audio/x-raw,channels=2 ! audioresample ! alsasink async=false sync=false )");
       //"( capsfilter caps=\"application/x-rtp, media=audio, payload=8, clock-rate=8000, encoding-name=PCMA, channels=1\" name=depay_backchannel ! rtpjitterbuffer latency=80 ! rtppcmadepay ! alawdec ! identity drop-probability=0.01 sync=true ! audioconvert ! audioresample ! alsasink async=false sync=false )");
   gst_rtsp_media_factory_set_shared (factory, FALSE);
   gst_rtsp_media_factory_set_media_gtype (factory, GST_TYPE_RTSP_ONVIF_MEDIA);

+ 12 - 44
Modules/service_process/main.c

@@ -126,8 +126,6 @@ typedef struct {
 } redis_client_t;
 
 static int BARESIP_STATUS = OFFLINE;
-static int key1LedStatus = Led_Off;
-static int key2LedStatus = Led_Off;
 static int CURRENT_KEY = UNKEY;
 static int DEBUG = FALSE;
 static int ACCOUNT1_REG = REGISTER_FAIL;
@@ -644,31 +642,6 @@ void screenControl(int enable){
     }
 }
 
-void ai_ctrl(Boolean en)
-{
-    char hversion[16];
-    GetCmdValue(SPK_CONF, "system:hard_version", hversion, sizeof(hversion));
-    if(en)
-    {
-        char ai[8];
-        GetCmdValue(SPK_CONF, "ai_settings:enable", ai, sizeof(ai));
-        if(strcmp(ai, "yes") == 0)
-        {
-            if(strcmp(hversion, "Ver3.2") == 0)
-                system("echo 1 > /sys/class/gpio/gpio143/value");
-            else
-                system("echo 1 > /sys/class/gpio/gpio134/value");
-        }
-    }
-    else
-    {
-        if(strcmp(hversion, "Ver3.2") == 0)
-            system("echo 0 > /sys/class/gpio/gpio143/value");
-        else
-            system("echo 0 > /sys/class/gpio/gpio134/value");
-    }
-}
-
 //relay延时控制
 void *relayDelayControl()
 {
@@ -694,9 +667,9 @@ void *screenDelayControl()
 void *key1ScreenDelayControl()
 {
     char delay[8], srceen_id[16], strtmp[64];
-    GetCmdValue(SPK_CONF, "intercom:screen_1_duration", delay, sizeof(delay));
+    GetCmdValue(SPK_CONF, "intercom:screen_duration", delay, sizeof(delay));
     usleep(atoi(delay)*1000*1000);
-    GetCmdValue(SPK_CONF, "intercom:trigger_1_id", srceen_id, sizeof(srceen_id));
+    GetCmdValue(SPK_CONF, "intercom:trigger_id", srceen_id, sizeof(srceen_id));
     sprintf(strtmp,"{\"action\": \"off\", \"id\": %s}",srceen_id);
     screen_control(strtmp);
     if(DEBUG)
@@ -782,8 +755,6 @@ void answeredTrigger()
     char screen_call_state[8], screen_state_info[16], screen_mode[16];
 
 	setAnswerCallInfo();
-    //切换麦克风通道为通话通道
-    ai_ctrl(FALSE);
     //判断RELAY是否需要应答复位
     GetCmdValue(SPK_CONF, "relay_ctrl:mode", relay_mode, sizeof(relay_mode));
     if( strcmp(relay_mode, "answered") == 0 )
@@ -1017,7 +988,6 @@ void ProcessReply( redisReply * pReply )
                 {
                     //amplifier_switch(FALSE);
                     CURRENT_CALLS = 0;
-                    ai_ctrl(TRUE);
                 }
                 else
                 {
@@ -1041,7 +1011,6 @@ void ProcessReply( redisReply * pReply )
                 if(CURRENT_CALLS < 1)
                 {
                     CURRENT_CALLS = 0;
-                    ai_ctrl(TRUE);
                 }
                 else
                 {
@@ -1359,8 +1328,8 @@ void keyAction(int key)
                     case IDLE:
                         CURRENT_KEY = KEY;
                         BARESIP_STATUS = DIALING;
-                        GetCmdValue(SPK_CONF, "intercom:onekey_1_num", onekey_num, sizeof(onekey_num));
-                        GetCmdValue(SPK_CONF, "intercom:onekey_1_line", onekey_line, sizeof(onekey_line));
+                        GetCmdValue(SPK_CONF, "intercom:onekey_num", onekey_num, sizeof(onekey_num));
+                        GetCmdValue(SPK_CONF, "intercom:onekey_line", onekey_line, sizeof(onekey_line));
                         if(strlen(onekey_num) == 0) 
                         {
                             BARESIP_STATUS = IDLE;
@@ -1444,7 +1413,7 @@ void keyAction(int key)
                         break;
                     case RINGING:
                     case INUSE:
-                        GetCmdValue(SPK_CONF, "intercom:repress_1_cancel", repress_cancel, sizeof(repress_cancel));
+                        GetCmdValue(SPK_CONF, "intercom:repress_cancel", repress_cancel, sizeof(repress_cancel));
                         if(strcmp(repress_cancel, "yes") == 0){
                             strcpy(cmd,"{\"cmd\":\"hangup\",\"data\":\"\"}");
                             if(DEBUG)
@@ -2105,8 +2074,7 @@ void sip_reg_status_init()
     }
     if(ACCOUNT1_REG == REGISTER_OK || ACCOUNT2_REG == REGISTER_OK || ACCOUNT3_REG == REGISTER_OK || ACCOUNTP2P_REG == REGISTER_OK)
     {
-        key1LedStatus = Led_On;
-        key2LedStatus = Led_On;
+
     }
 }
 
@@ -2212,26 +2180,26 @@ int main(int argc, char *argv[]){
                 if(DEBUG)
                     printf("KEY DOWN\n");
                 writeLog(BTN, "KEY", "DOWN");
-                GetCmdValue(SPK_CONF, "intercom:key_1_action", action, sizeof(action));
+                GetCmdValue(SPK_CONF, "intercom:key_action", action, sizeof(action));
                 if(strcmp(action,"call") == 0)
                 {
                     keyAction(KEY);
                 }
                 if(strcmp(action,"http") == 0)
                 {
-                    GetCmdValue(SPK_CONF, "intercom:http_1_url", url, sizeof(url));
+                    GetCmdValue(SPK_CONF, "intercom:http_url", url, sizeof(url));
                     action_url(url);
-	                writeLog(FUN, "KEY1 HTTP Request", url);
+	                writeLog(FUN, "KEY HTTP Request", url);
                 }
                 else if(strcmp(action,"play") == 0)
                 {
                     char audiofile[32],repeat_tmp[16];
-                    GetCmdValue(SPK_CONF, "intercom:audio_1_file", audiofile, sizeof(audiofile));
-                    GetCmdValue(SPK_CONF, "intercom:audio_1_repeat", repeat_tmp, sizeof(repeat_tmp));
+                    GetCmdValue(SPK_CONF, "intercom:audio_file", audiofile, sizeof(audiofile));
+                    GetCmdValue(SPK_CONF, "intercom:audio_repeat", repeat_tmp, sizeof(repeat_tmp));
                     int repeat = atoi(repeat_tmp);
                     play_audio(audiofile,repeat);
                     sprintf(strtmp, "File: %s; Repeat: %d", audiofile, repeat);
-                    writeLog( FUN, "KEY1 Play Auido", strtmp );
+                    writeLog( FUN, "KEY Play Auido", strtmp );
                 }
             }
         }

+ 1 - 1
Modules/sipconf/main.c

@@ -8,7 +8,7 @@
 #define TRUE        1
 #define FALSE       0
 #define ALSA_DEF    "alsa,default"
-#define ALSA_PLUGHW "alsa,default"
+#define ALSA_PLUGHW "alsa,plug:mixmic"
 #define SPK_CONF    "/oem/etc/speaker.conf"
 #define ACC_CONF    "/tmp/accounts"
 #define SPHONE_MODULE_CONF  "/tmp/config"

+ 17 - 0
etc/asound.conf

@@ -0,0 +1,17 @@
+
+
+pcm.mixmic_1 {
+	ipc_key 1026
+	type dsnoop
+	slave {
+		pcm "hw:0"
+		channels 4
+		period_size 1024
+		buffer_size 262144
+	}
+}
+
+pcm.mixmic {
+	type plug
+	slave.pcm "mixmic_1"
+}

BIN
etc/scripts/api_agent


BIN
etc/scripts/output_control


BIN
etc/scripts/rtspserver


BIN
etc/scripts/service_process


BIN
etc/scripts/sipconf


+ 8 - 8
etc/scripts/watch_process.sh

@@ -43,14 +43,14 @@ start()
                         wd_c=`expr $wd_c + 1`
                 fi
 
-                # ONVIFSERVER_STAT="`ps|grep -w onvifserver|grep -v grep`"
-                # RTSPSERVER_STAT="`ps|grep -w rtspserver|grep -v grep`"
-                # if [ -z "${ONVIFSERVER_STAT}" -o -z "${RTSPSERVER_STAT}" ];then
-                #         ONVIF_ENABLE="`sysconf /etc/speaker.conf get onvif enable`"
-                #         if [ "foo${ONVIF_ENABLE}" = "fooyes" ];then
-                #                 /etc/scripts/shell_action.sh set_onvif
-                #         fi
-                # fi
+                ONVIFSERVER_STAT="`ps|grep -w onvifserver|grep -v grep`"
+                RTSPSERVER_STAT="`ps|grep -w rtspserver|grep -v grep`"
+                if [ -z "${ONVIFSERVER_STAT}" -o -z "${RTSPSERVER_STAT}" ];then
+                        ONVIF_ENABLE="`sysconf /etc/speaker.conf get onvif enable`"
+                        if [ "foo${ONVIF_ENABLE}" = "fooyes" ];then
+                                /etc/scripts/shell_action.sh set_onvif
+                        fi
+                fi
 
                 ONVIF_STAT="`ps -e|grep 'onvif-discover'|grep -v grep`"
                 if [ -z "${ONVIF_STAT}" ];then