Squashed 'LYNQ_PUBLIC/' content from commit 79d8f932f
git-subtree-dir: LYNQ_PUBLIC
git-subtree-split: 79d8f932fb4ebc4b5aec6c5ace97634912394272
Change-Id: If2527ba937f56fe989487bf71e996f7cfd9fbe61
diff --git a/common_src/lib/liblynq-media/LICENSE b/common_src/lib/liblynq-media/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/lib/liblynq-media/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/lib/liblynq-media/MODULE_LICENSE_APACHE2 b/common_src/lib/liblynq-media/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common_src/lib/liblynq-media/MODULE_LICENSE_APACHE2
diff --git a/common_src/lib/liblynq-media/Makefile b/common_src/lib/liblynq-media/Makefile
new file mode 100644
index 0000000..e1e1c50
--- /dev/null
+++ b/common_src/lib/liblynq-media/Makefile
@@ -0,0 +1,63 @@
+PREFIX = ../install
+CROSS = arm-none-linux-
+ROOT = $(PREFIX)/$(CROSS:%-=%)
+
+#For Yocto use
+
+RFX_TEST_CLIENT = false
+RFX_TEST_AOSP = false
+
+$(warning ########## libvendor_ril BB_TELEFWK_OPTION $(BB_TELEFWK_OPTION) ##########)
+
+
+
+SUBDIRS += liblynq-media
+
+
+
+
+
+$(warning ########## lynq-rilcmd SUBDIRS $(SUBDIRS) ##########)
+export SIM_COUNT?=1
+
+.PHONY: all build clean pack_rootfs
+
+all: build
+
+build: clean
+
+clean:
+ $(warning ########## clean ril ##########)
+ for i in $(SUBDIRS); do \
+ (cd $$i && make clean); \
+ if [ $$? != 0 ]; then \
+ exit 1; \
+ fi \
+ done
+
+build:
+ $(warning ########## build ril ##########)
+ for i in $(SUBDIRS); do \
+ (cd $$i && make); \
+ if [ $$? != 0 ]; then \
+ exit 1; \
+ fi \
+ done
+
+install:
+ $(warning ########## install ril ##########)
+ for i in $(SUBDIRS); do \
+ (cd $$i && make install); \
+ if [ $$? != 0 ]; then \
+ exit 1; \
+ fi \
+ done
+
+pack_rootfs:
+ $(warning ########## pack_rootfs ril ##########)
+ for i in $(SUBDIRS); do \
+ (cd $$i && make pack_rootfs); \
+ if [ $$? != 0 ]; then \
+ exit 1; \
+ fi \
+ done
diff --git a/common_src/lib/liblynq-media/NOTICE b/common_src/lib/liblynq-media/NOTICE
new file mode 100644
index 0000000..c5b1efa
--- /dev/null
+++ b/common_src/lib/liblynq-media/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2008, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/common_src/lib/liblynq-media/README b/common_src/lib/liblynq-media/README
new file mode 100644
index 0000000..9a7e82f
--- /dev/null
+++ b/common_src/lib/liblynq-media/README
@@ -0,0 +1,13 @@
+WHAT IT DOES?
+=============
+MTK ril proxy core library
+
+HOW IT WAS BUILT?
+==================
+This module is source code released.
+
+HOW TO USE IT?
+==============
+MTK ril proxy daemon will use this library to communicate with GSM and C2K RILD.
+
+All the source code of this folder were written by MediaTek co..
diff --git a/common_src/lib/liblynq-media/include/liblynq-media/lynq_medial.h b/common_src/lib/liblynq-media/include/liblynq-media/lynq_medial.h
new file mode 100755
index 0000000..28f18af
--- /dev/null
+++ b/common_src/lib/liblynq-media/include/liblynq-media/lynq_medial.h
@@ -0,0 +1,43 @@
+#ifndef __LYNQ_MEDIA_H__
+#define __LYNQ_MEDIA_H__
+typedef enum {
+ VOLUME_LEVEL1= 1,
+ VOLUME_LEVEL2,
+ VOLUME_LEVEL3,
+ VOLUME_LEVEL4,
+ VOLUME_LEVEL5,
+ VOLUME_LEVEL6,
+ VOLUME_LEVEL7,
+}volume_level_t;
+typedef enum {
+ MIC_VOLUME_LEVEL1= 1,
+ MIC_VOLUME_LEVEL2,
+ MIC_VOLUME_LEVEL3,
+ MIC_VOLUME_LEVEL4,
+ MIC_VOLUME_LEVEL5,
+ MIC_VOLUME_LEVEL6,
+ MIC_VOLUME_LEVEL7,
+}mic_volume_level_t;
+
+#define VOLUME_MAX 7
+#define VOLUME_MIN 1
+
+int lynq_spk_volume_up();
+int lynq_spk_volume_down();
+int lynq_get_spk_volume(int* volume);
+int lynq_set_spk_volume(const int volume);
+int lynq_get_mic_volume(int* volume);
+int lynq_set_mic_volume(const int volume);
+int lynq_get_pa_volume(int* volume);
+int lynq_set_pa_volume(const int volume);
+
+/*dongyu@2023.6.27 Add Tone sound play, stop and status acquisition interface start*/
+int lynq_set_audtone(double high_freq, double low_freq, double duration, \
+ int stop_interval, int num_repetitions);
+int lynq_get_audtone(double* high_freq, double* low_freq, double* duration, \
+ int* stop_interval, int* num_repetitions);
+void lynq_stop_audtone();
+/*dongyu@2023.6.27 Add Tone sound play, stop and status acquisition interface end*/
+int lynq_media_play_audio(const char *path);
+void lynq_media_stop_audio();
+#endif //__LYNQ_MEDIA_H__
diff --git a/common_src/lib/liblynq-media/include/liblynq-media/lynq_modem_voice.h b/common_src/lib/liblynq-media/include/liblynq-media/lynq_modem_voice.h
new file mode 100644
index 0000000..dcf301e
--- /dev/null
+++ b/common_src/lib/liblynq-media/include/liblynq-media/lynq_modem_voice.h
@@ -0,0 +1,12 @@
+#ifndef __LYNQ_MODEM_VOICE_H__
+#define __LYNQ_MODEM_VOICE_H__
+int lynq_audio_init();//mixer_init
+int lynq_audio_set(int value );//mixer_set
+int lynq_set_modem_volume(int value);//mixer_set_volume
+int lynq_get_modem_volume();//mixer_get_volume
+int lynq_incall_record(char* file_path);
+int lynq_stop_record();
+int lynq_set_call_mute(int mute);//setCallMute
+int lynq_get_call_mute();//getCallMute
+void lynq_reset_mute();//resetMute
+#endif //__LYNQ_MODEM_VOICE_H__
\ No newline at end of file
diff --git a/common_src/lib/liblynq-media/liblynq-media/makefile b/common_src/lib/liblynq-media/liblynq-media/makefile
new file mode 100644
index 0000000..323f88b
--- /dev/null
+++ b/common_src/lib/liblynq-media/liblynq-media/makefile
@@ -0,0 +1,84 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -fPIC \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -DECALL_SUPPORT \
+
+$(warning ################# RITA ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(LOCAL_PATH)/../include/liblynq-media \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(includedir)/gstreamer-1.0 \
+ -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+
+
+
+LOCAL_LIBS := \
+ -L. \
+ -lmtk_audio_mixer_ctrl \
+ -luciwrapper \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lcutils \
+ -lutils \
+ -lasound \
+ -lpal \
+ -lpthread \
+ -lgstreamer-1.0 \
+ -lglib-2.0 \
+ -lgstbase-1.0 \
+ -lgstreamer-1.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldtmf \
+ -lapn \
+ -llynq-codec \
+
+
+
+SOURCES = $(wildcard *.c wildcard *.h)
+
+EXECUTABLE = liblynq-media.so
+
+OBJECTS=$(SOURCES:.c=.o)
+
+
+.PHONY: build clean install pack_rootfs
+
+all: build
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+build: $(EXECUTABLE)
+ $(warning ########## build $(EXECUTABLE) ##########)
+
+install:
+ mkdir -p $(ROOT)$(base_libdir)/
+ install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+ mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+
+pack_rootfs:
+ mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+ cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+ $(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+ mkdir -p $(PACK_TO)$(base_libdir)/
+ cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+ $(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/lib/liblynq-media/liblynq-media/media_control.c b/common_src/lib/liblynq-media/liblynq-media/media_control.c
new file mode 100755
index 0000000..20e9a8a
--- /dev/null
+++ b/common_src/lib/liblynq-media/liblynq-media/media_control.c
@@ -0,0 +1,635 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "lynq_medial.h"
+#include <syslog.h>
+#include <gst/gst.h>
+#include <pthread.h>
+#include <cutils/properties.h>
+//#include "modem_afe_ctrl.h"
+#include <fcntl.h>
+#include <linux/i2c-dev.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <math.h>
+#include <unistd.h>
+#include <pthread.h>
+#define AUDIO_PATH get_customer_tone_path()
+#define SAMPLE_RATE get_customer_tone_sample_rate()
+typedef struct {
+ size_t size;
+ unsigned short* data;
+ double high_freq;
+ double low_freq;
+ double duration;
+ int stop_interval;
+ int num_repetitions;
+} wav_t;
+wav_t g_current_tone = {0};
+#include <log/log.h>
+#include "liblynq-codec/lynq_codec.h"
+#define LOG_TAG "MEDIA_API"
+#define NV_VOLUME_NAME "ro.spk.volume.level"
+#define NV_MIC_VOLUME_NAME "ro.mic.volume.level"
+//static char *volume_rcv = "/tmp/libmodem-afe-ctrl/server_rcv";
+static const int VOLUME_LEVEL_1 = 1;//0;
+static const int VOLUME_LEVEL_2 = 22;//200;
+static const int VOLUME_LEVEL_3 = 43;//209;
+static const int VOLUME_LEVEL_4 = 64;//220;
+static const int VOLUME_LEVEL_5 = 85;//234;
+static const int VOLUME_LEVEL_6 = 106;//245;
+static const int VOLUME_LEVEL_7 = 127;//255;
+
+static const int MIC_VOLUME_LEVEL_1 = 9;
+static const int MIC_VOLUME_LEVEL_2 = 19;
+static const int MIC_VOLUME_LEVEL_3 = 28;
+static const int MIC_VOLUME_LEVEL_4 = 37;
+static const int MIC_VOLUME_LEVEL_5 = 46;
+static const int MIC_VOLUME_LEVEL_6 = 55;
+static const int MIC_VOLUME_LEVEL_7 = 63;
+
+typedef void *MEDIA_HANDLE;
+volatile static MEDIA_HANDLE g_media_handle=NULL;
+
+typedef struct {
+ MEDIA_HANDLE handle;
+ gint mute;
+ gdouble volume;
+ pthread_t thread;
+ GMainLoop *loop;
+ GstElement *playbin;
+ guint bus_watch_id;
+ GstState gst_cur_state;
+} MEDIA_PARAM_T;
+
+static gboolean
+ bus_call (GstBus * bus, GstMessage * msg, gpointer datas)
+ {
+ GstState oldstate, newstate, pending;
+ MEDIA_PARAM_T *param = (MEDIA_PARAM_T *)datas;
+ GMainLoop *loop = param->loop;
+ switch (GST_MESSAGE_TYPE (msg)) {
+ case GST_MESSAGE_EOS:{
+ RLOGD ("End-of-stream\n");
+ g_main_loop_quit (loop);
+ break;
+ }
+ case GST_MESSAGE_STATE_CHANGED:
+ gst_message_parse_state_changed (msg, &oldstate, &newstate, &pending);
+ param->gst_cur_state = newstate;
+ break;
+ case GST_MESSAGE_ERROR:{
+ gchar *debug;
+ GError *err;
+ gst_message_parse_error (msg, &err, &debug);
+ g_printerr ("Debugging info: %s\n", (debug) ? debug : "none");
+ g_free (debug);
+ RLOGD ("Error: %s\n", err->message);
+ g_error_free (err);
+
+ g_main_loop_quit (loop);
+
+ break;
+ }
+ default:
+ break;
+ }
+ return TRUE;
+ }
+int lynq_get_mic_current_volume()
+{
+ char cvolume_levle[5]= {0};
+ property_get(NV_MIC_VOLUME_NAME, cvolume_levle, "5");
+ printf("lynq_media_get_current_volume end :%s\n" ,cvolume_levle);
+ return atoi(cvolume_levle);
+
+}
+static void lynq_set_mic_volume_to_nvram(const int volume_levle )
+{
+ char buf[5];
+ sprintf(buf, "%d", volume_levle);
+ property_set(NV_MIC_VOLUME_NAME, buf);
+
+}
+static int lynq_set_mic_real_volume(const int real_volume)
+{
+ char cmd[256];
+ RLOGD("mic real volume: %d \n", real_volume);
+ sprintf(cmd, "amixer -c0 cset name=\"PGA Volume\" %d", real_volume);
+ system(cmd);
+ return 0;
+}
+static int get_mic_real_volume(const int volume_levle)
+{
+ int real_volume;
+ switch (volume_levle) {
+ case MIC_VOLUME_LEVEL1:
+ real_volume = MIC_VOLUME_LEVEL_1;
+ break;
+ case MIC_VOLUME_LEVEL2:
+ real_volume = MIC_VOLUME_LEVEL_2;
+ break;
+ case MIC_VOLUME_LEVEL3:
+ real_volume = MIC_VOLUME_LEVEL_3;
+ break;
+ case MIC_VOLUME_LEVEL4:
+ real_volume = MIC_VOLUME_LEVEL_4;
+ break;
+ case MIC_VOLUME_LEVEL5:
+ real_volume = MIC_VOLUME_LEVEL_5;
+ break;
+ case MIC_VOLUME_LEVEL6:
+ real_volume = MIC_VOLUME_LEVEL_6;
+ break;
+ case MIC_VOLUME_LEVEL7:
+ real_volume = MIC_VOLUME_LEVEL_7;
+ break;
+ default:
+ syslog(LOG_ERR, "Not the correct parameter");
+ return 0;
+ }
+ return real_volume;
+}
+ int lynq_set_mic_volume(const int volume) {
+ int real_volume;
+ if((volume>MIC_VOLUME_LEVEL7)||(volume<MIC_VOLUME_LEVEL1))
+ return 1;
+ lynq_set_mic_volume_to_nvram(volume);
+ real_volume = get_mic_real_volume(volume);
+ lynq_set_mic_real_volume(real_volume);
+ return 0;
+}
+
+int lynq_get_mic_volume(int* volume) {
+ if(volume==NULL)
+ {
+ return 1;
+ }
+
+ (*volume) = lynq_get_mic_current_volume();
+ return 0;
+}
+int lynq_get_spk_current_volume()
+{
+ char cvolume_levle[5] = {0};
+ property_get(NV_VOLUME_NAME, cvolume_levle, "5");
+ printf("lynq_media_get_current_volume end :%s\n" ,cvolume_levle);
+ return atoi(cvolume_levle);
+
+}
+static void lynq_set_spk_volume_to_nvram(const int volume_levle )
+{
+ char buf[5] = {0};
+ sprintf(buf, "%d", volume_levle);
+ property_set(NV_VOLUME_NAME, buf);
+}
+static int lynq_set_spk_real_volume(const int volume)
+{
+ char cmd[256];
+ RLOGD("spk real volume: %d \n", volume);
+ // sprintf(cmd, "amixer -c0 cset name=\"Playback Volume\" %d", volume);
+ sprintf(cmd, "amixer -c0 cset name=\"Line DAC Playback Volume\" %d", volume);
+ system(cmd);
+ return 0;
+}
+static int get_spk_real_volume(const int volume_levle)
+{
+ int real_volume;
+ switch (volume_levle) {
+ case VOLUME_LEVEL1:
+ real_volume = VOLUME_LEVEL_1;
+ break;
+ case VOLUME_LEVEL2:
+ real_volume = VOLUME_LEVEL_2;
+ break;
+ case VOLUME_LEVEL3:
+ real_volume = VOLUME_LEVEL_3;
+ break;
+ case VOLUME_LEVEL4:
+ real_volume = VOLUME_LEVEL_4;
+ break;
+ case VOLUME_LEVEL5:
+ real_volume = VOLUME_LEVEL_5;
+ break;
+ case VOLUME_LEVEL6:
+ real_volume = VOLUME_LEVEL_6;
+ break;
+ case VOLUME_LEVEL7:
+ real_volume = VOLUME_LEVEL_7;
+ break;
+ default:
+ syslog(LOG_ERR, "Not the correct parameter");
+ return 0;
+ }
+ return real_volume;
+}
+int lynq_spk_volume_up()
+{
+ int real_volume,current_volume;
+ current_volume = lynq_get_spk_current_volume();
+ if(VOLUME_LEVEL7 == current_volume)
+ {
+ return 1;
+ }
+ else
+ {
+ lynq_set_spk_volume_to_nvram(current_volume+1);
+ real_volume = get_spk_real_volume(current_volume+1);
+ lynq_set_spk_real_volume(real_volume);
+ return 0;
+ }
+
+}
+int lynq_spk_volume_down()
+{
+ int real_volume,current_volume;
+ current_volume = lynq_get_spk_current_volume();
+
+ if(VOLUME_LEVEL1 == current_volume)
+ {
+ return 1;
+ }
+ else
+ {
+ lynq_set_spk_volume_to_nvram(current_volume-1);
+ real_volume = get_spk_real_volume(current_volume-1);
+ lynq_set_spk_real_volume(real_volume);
+ return 0;
+ }
+
+}
+
+int lynq_set_spk_volume(const int volume)
+{
+ if((volume>VOLUME_LEVEL7)||(volume<VOLUME_LEVEL1))
+ return 1;
+ lynq_set_spk_volume_to_nvram(volume);
+ int real_volume = get_spk_real_volume(volume);
+ lynq_set_spk_real_volume(real_volume);
+ return 0;
+}
+int lynq_get_spk_volume(int* volume) {
+ if(volume==NULL)
+ {
+ return 1;
+ }
+ (*volume) = lynq_get_spk_current_volume();
+ return 0;
+}
+
+/*dongyu@2023.6.27 Add Tone sound play, stop and status acquisition interface start*/
+static int is_current_media_playing()
+{
+ if (g_media_handle == NULL)
+ {
+ RLOGD("is_current_media_playing g_media_handle is NULL\n");
+ return 0;
+ }
+
+ MEDIA_PARAM_T *param = (MEDIA_PARAM_T *)g_media_handle;
+
+ if (g_media_handle != param->handle)
+ {
+ RLOGD("invalid handle: %p \n", g_media_handle);
+ }
+
+ if (param->gst_cur_state == GST_STATE_PLAYING)
+ {
+ RLOGE("Error: already in playback state\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static int lynq_generate_wav(double high_freq, double low_freq, double duration, wav_t* wav)
+{
+ int num_repeats = 10;
+ int num_samples = (int)(SAMPLE_RATE * duration);
+ wav->size = num_samples * sizeof(int16_t);
+ wav->data = (int16_t*)malloc(wav->size);
+ if(wav->data == NULL)
+ {
+ RLOGE("Memory allocation failed\n");
+ return -1;
+ }
+ for (int i = 0; i < num_samples; i++)
+ {
+ double t = (double)i / SAMPLE_RATE;
+ double signal1 = 0.0;
+ double signal2 = 0.0;
+ for (int j = 0; j < num_repeats; j++)
+ {
+ double f = (j % 2 == 0) ? high_freq : low_freq;
+ signal1 += sin(2.0 * M_PI * f * t);
+ f = (j % 2 == 0) ? low_freq : high_freq;
+ signal2 += sin(2.0 * M_PI * f * t);
+ }
+ double signal = (signal1 + signal2) / 2;
+ wav->data[i] = (int16_t)(32767.0 * signal / num_repeats);
+ if (i % (int)(SAMPLE_RATE * 50) == 0)
+ {
+ num_repeats = (num_repeats == 1) ? 2 : 1;
+ }
+ }
+ return 0;
+}
+
+int lynq_set_audtone(double high_freq, double low_freq, double duration, \
+ int stop_interval, int num_repetitions)
+{
+ if(high_freq<100 || high_freq>4000 || low_freq<100 || low_freq>4000 || \
+ duration<0 || duration>60000 || \
+ stop_interval<0 || stop_interval>60000 || \
+ num_repetitions<1 || num_repetitions>300)
+ {
+ RLOGE("Frequency range is 100Hz~4KHz, duration range is 0~60000ms, "
+ "stop_interval range is 0~60000ms, num_repetitions range is 1~300\n");
+ return -1;
+ }
+ RLOGE("SET: high_freq=%.2f, low_freq=%.2f, duration=%.2f, "
+ "stop_interval=%d, num_repetitions=%d\n", high_freq, \
+ low_freq, duration, stop_interval, num_repetitions);
+
+ //Checks if the aplay exists before entering the thread
+ if(is_current_media_playing() != 0)
+ {
+ RLOGE("There is currently media playing\n");
+ return 1;
+ }
+
+ wav_t wav = {0};
+ if(lynq_generate_wav(high_freq, low_freq, duration / 1000.0, &wav) != 0)
+ {
+ RLOGE("Failed to generate wav\n");
+ free(wav.data);
+ return -1;
+ }
+
+ wav_t stop_wav = {0};
+ if(lynq_generate_wav(0, 0, stop_interval / 1000.0, &stop_wav) != 0)
+ {
+ RLOGE("Failed to generate top wav\n");
+ free(wav.data);
+ free(stop_wav.data);
+ return -1;
+ }
+
+ FILE* file = fopen(AUDIO_PATH, "wb");
+ if(file == NULL)
+ {
+ RLOGE("Failed to open file\n");
+ free(wav.data);
+ free(stop_wav.data);
+ return -1;
+ }
+ fwrite("RIFF", 1, 4, file);
+ int chunk_size = 36 + num_repetitions * (wav.size + stop_wav.size);
+ fwrite(&chunk_size, 4, 1, file);
+ fwrite("WAVE", 1, 4, file);
+ fwrite("fmt ", 1, 4, file);
+ int subchunk1_size = 16;
+ fwrite(&subchunk1_size, 4, 1, file);
+ unsigned short audio_format = 1;
+ fwrite(&audio_format, 2, 1, file);
+ unsigned short num_channels = 1;
+ fwrite(&num_channels, 2, 1, file);
+ int sample_rate = SAMPLE_RATE;
+ fwrite(&sample_rate, 4, 1, file);
+ int byte_rate = SAMPLE_RATE * 2;
+ fwrite(&byte_rate, 4, 1, file);
+ unsigned short block_align = 2;
+ fwrite(&block_align, 2, 1, file);
+ unsigned short bits_per_sample = 16;
+ fwrite(&bits_per_sample, 2, 1, file);
+ fwrite("data", 1, 4, file);
+ int subchunk2_size = num_repetitions * (wav.size + stop_wav.size);
+ fwrite(&subchunk2_size, 4, 1, file);
+
+ for (int i = 0; i < num_repetitions; i++)
+ {
+ fwrite(wav.data, 1, wav.size, file);
+ fwrite(stop_wav.data, 1, stop_wav.size, file);
+ }
+
+ fclose(file);
+ free(wav.data);
+ free(stop_wav.data);
+
+ g_current_tone.high_freq = high_freq;
+ g_current_tone.low_freq = low_freq;
+ g_current_tone.duration = duration;
+ g_current_tone.stop_interval = stop_interval;
+ g_current_tone.num_repetitions = num_repetitions;
+ g_current_tone.size = wav.size;
+ g_current_tone.data = wav.data;
+
+ if(lynq_media_play_audio(AUDIO_PATH) != 0)
+ {
+ RLOGE("Failed to play WAV fileln");
+ return -1;
+ }
+
+ printf("lynq_set_audtone is playing audio !\n");
+
+ return 0;
+}
+
+int lynq_get_audtone(double* high_freq, double* low_freq, double* duration, \
+ int* stop_interval, int* num_repetitions)
+{
+ if(high_freq == NULL || low_freq == NULL || duration == NULL || \
+ stop_interval == NULL || num_repetitions == NULL){
+ RLOGE("lynq_get_audtone Pointers are NULL, returning -1\n");
+ return -1;
+ }
+
+ *high_freq = g_current_tone.high_freq;
+ *low_freq = g_current_tone.low_freq;
+ *duration = g_current_tone.duration;
+ *stop_interval = g_current_tone.stop_interval;
+ *num_repetitions = g_current_tone.num_repetitions;
+
+ return 0;
+}
+
+void lynq_stop_audtone()
+{
+ lynq_media_stop_audio();
+ RLOGD("lynq_stop_audtone stop audio playback\n");
+}
+
+/*dongyu@2023.6.27 Add Tone sound play, stop and status acquisition interface end*/
+/*dongyu@2023.6.13 Add ZK set the PA's volume gain level start*/
+int lynq_set_pa_volume(const int volume)
+{
+ return customer_set_pa_volume(volume);
+}
+
+
+int lynq_get_pa_volume(int* volume)
+{
+ return customer_get_pa_volume(volume);
+}
+
+/*dongyu@2023.6.13 Add ZK set the PA's volume gain level end*/
+static int media_stop_full(MEDIA_PARAM_T *param)
+{
+ GMainLoop *loop = param->loop;
+ GstElement *playbin = param->playbin;
+ guint bus_watch_id = param->bus_watch_id;
+ GstEvent *event_stop = NULL;
+ if (param != param->handle) {
+ RLOGE("invalid handle: %p \n", param->handle);
+ return 1;
+ }
+ param->handle = NULL;
+ gst_element_set_state (playbin, GST_STATE_NULL);
+ gst_object_unref (GST_OBJECT (playbin));
+ g_source_remove (bus_watch_id);
+ g_main_loop_unref (loop);
+
+ free(param);
+ set_codec(LYNQ_MEDIA, CODEC_CLOSE); //hqing add for Geely demand on 11/07/2022, stop audio, close codec
+ param = NULL;
+ g_media_handle=NULL;
+ RLOGI("media_stop_full Thread exit\n");
+ return 0;
+
+}
+
+void* media_thread_func(void *arg)
+{
+ MEDIA_PARAM_T *param = (MEDIA_PARAM_T *)arg;
+ RLOGD("%s start \n", __FUNCTION__);
+ g_main_loop_run (param->loop);
+ RLOGD("g_main_loop_run end \n");
+
+ media_stop_full(param);
+ return ((void *)0);
+}
+ static void start_main_loop(const MEDIA_PARAM_T *param)
+{
+ pthread_attr_t attr;
+ pthread_attr_init( &attr );
+ pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
+ pthread_create(&(param->thread), &attr, (void *)media_thread_func, param);
+}
+
+int lynq_media_play_audio(const char *path)
+{
+
+ GstBus *bus;
+ GstMessage *msg;
+ GMainLoop *loop;
+ GstElement *playbin;
+ gchar *uri;
+ guint bus_watch_id;
+ int ret;
+ pthread_t thread;
+ int cnt;
+ MEDIA_HANDLE handle = NULL;
+ MEDIA_PARAM_T *param;
+
+ if(g_media_handle!=NULL)
+ {
+ RLOGE ("media is running.\n");
+ return 1;
+ }
+
+ param = malloc(sizeof(MEDIA_PARAM_T));
+
+ if (param == NULL) {
+ RLOGE ("malloc MEDIA_PARAM_T fail \n");
+ return 1;
+ }
+ memset(param, 0, sizeof(MEDIA_PARAM_T));
+ handle = (MEDIA_HANDLE)param;
+ g_media_handle=handle;
+ param->mute = 0;
+ param->volume = 1.0;
+ gst_init (NULL, NULL);
+ loop = g_main_loop_new (NULL, FALSE);
+ playbin = gst_element_factory_make ("playbin", "playbin");
+ RLOGD ("main start.\n");
+ if (!playbin) {
+ g_printerr ("Not all elements could be created.\n");
+ free(param);
+ g_media_handle=NULL;
+ return 1;
+ }
+
+ if (gst_uri_is_valid (path))
+ uri = g_strdup (path);
+ else
+ uri = gst_filename_to_uri (path, NULL);
+ g_object_set (playbin, "uri", uri, NULL);
+ g_object_set (playbin, "flags",0x42,NULL);
+ g_object_set (playbin, "volume",param->volume,NULL);
+ g_object_set (playbin, "mute",param->mute,NULL);
+
+ bus = gst_element_get_bus (playbin);
+ bus_watch_id = gst_bus_add_watch (bus, bus_call, (gpointer)param);
+ g_object_unref (bus);
+ param->playbin = playbin;
+ param->bus_watch_id = bus_watch_id;
+ param->thread = thread;
+ param->loop = loop;
+ param->handle = handle;
+ start_main_loop(param);
+ RLOGD ("gst_bus_add_watch.\n");
+ set_codec(LYNQ_MEDIA, CODEC_OPEN); //hqing add for Geely demand on 11/07/2022, play audio, open codec
+ gst_element_set_state (playbin, GST_STATE_PLAYING);
+ cnt=0;
+ do {
+ if (param->gst_cur_state == GST_STATE_PLAYING)
+ {
+ break;
+ }
+ else
+ {
+ if (cnt==6){
+ RLOGD ("After 6s, not enter playing state.\n");
+ lynq_media_stop_audio();
+ return 1;
+ }
+ cnt++;
+ usleep(100000);
+ }
+ } while (1);
+ RLOGD ("lynq_media_play_audio end, handle is %p\n",handle);
+ return 0;
+}
+
+void lynq_media_stop_audio()
+{
+ if (g_media_handle == NULL) {
+ RLOGE ("%s, g_media_handle is NULL\n", __FUNCTION__);
+ return;
+ }
+ MEDIA_PARAM_T *param = (MEDIA_PARAM_T *)g_media_handle;
+
+ if (g_media_handle != param->handle) {
+ RLOGE("invalid handle: %p \n", g_media_handle);
+ }
+
+ g_main_loop_quit (param->loop);
+ pthread_join(param->thread, NULL);
+ RLOGD ("lynq_media_stop_audio end\n");
+
+ for (int i = 0; i < 50; i++)
+ {
+ if (g_media_handle == NULL)
+ {
+ RLOGD("Exit media_stop_full\n");
+ return;
+ }
+ usleep(100000);
+ RLOGD("lynq_media_stop_audio loop %d times\n", i);
+ }
+
+ return;
+}
+
+
+
diff --git a/common_src/lib/liblynq-media/liblynq-media/modem_voice_control.c b/common_src/lib/liblynq-media/liblynq-media/modem_voice_control.c
new file mode 100644
index 0000000..9cedd2e
--- /dev/null
+++ b/common_src/lib/liblynq-media/liblynq-media/modem_voice_control.c
@@ -0,0 +1,255 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "lynq_modem_voice.h"
+#include <syslog.h>
+#include <log/log.h>
+#define LOG_TAG "MEDIA_API"
+#include <dtmf.h>
+#include "mixer_ctrl.h"
+
+const char g_card_name[] = "mtk_phonecall";
+/*for speech on*/
+const char g_mixer_name[] = "Speech_on";
+const char g_mixer_name_volume[] = "DL Call Playback Volume";
+const char g_DL_mute_name[] = "Speech_DL_mute";
+const char g_UL_mute_name[] = "Speech_UL_mute";
+GstElement *pipeline_element;
+static int inCallRecordMode = 0;
+static int gst_status = 0;
+
+ int lynq_audio_init() //mixer_init
+{
+ int ret;
+
+ // only need to set card name once
+ ret = set_card_name(g_card_name);
+ if (ret)
+ RLOGE("set_card_name err: %d", ret);
+ return ret;
+}
+
+ int lynq_audio_set(int value )//mixer_set
+{
+ int ret;
+
+ //set mixer ctl to om:1 or off:0
+ ret = set_mixer_ctrl_value_int(g_mixer_name, value);
+ if (ret)
+ RLOGE("set_mixer_ctrl_value_int g_mixer_name err: %d", ret);
+ return ret;
+}
+/*
+int mixer_reset_set(int value )
+{
+ int ret;
+
+ // set mixer to reset:1
+ ret = set_mixer_ctrl_value_int(g_mixer_reset_name, value);
+ if (ret)
+ RLOGE("set_mixer_ctrl_value_int g_mixer_reset_name err: %d", ret);
+ return ret;
+}*/
+
+
+
+
+
+int lynq_set_spk_modem_volume(int value)//mixer_set_volume
+{
+ int ret;
+ // if (get_audio_path() == 0) {
+ ret = set_mixer_ctrl_volume_value(g_mixer_name_volume, value);
+ // } else {
+ // ret = set_mixer_ctrl_volume_value(g_mixer_name_volume_bt, value);
+ // }
+ if (ret)
+ RLOGE("set_mixer_ctrl_volume_value_int err: %d", ret);
+ return ret;
+}
+
+
+ int lynq_get_spk_modem_volume()//mixer_get_volume
+{
+ long int vol_value;
+ // if (get_audio_path() == 0) {
+ vol_value = get_mixer_ctrl_volume_value(g_mixer_name_volume);
+ // } else {
+ // vol_value = get_mixer_ctrl_volume_value(g_mixer_name_volume_bt);
+ // }
+ RLOGD("The ctrl \"%s\" is set to %d", g_mixer_name_volume, vol_value);
+ return vol_value;
+}
+
+static int GSM_Init(char* filepath){
+ GstElement *pipeline, *source, *mux, *encoder, *sink;
+ RLOGD("[GSM]GSM Init Start!");
+ /* Initialisation */
+ gst_init (NULL, NULL);
+
+ pipeline = gst_pipeline_new ("3gppmux-test");
+ source = gst_element_factory_make ("pulsesrc", "file-source");
+ encoder = gst_element_factory_make ("faac", "encoder");
+ mux = gst_element_factory_make ("3gppmux", "muxer");
+ sink = gst_element_factory_make ("filesink", "output");
+
+ g_object_set(mux, "fragment-duration", 100, NULL);
+ g_object_set(sink, "location", filepath, NULL);
+
+ if (!pipeline || !source || !encoder || !mux || !sink) {
+ if(pipeline) {
+ gst_object_unref (GST_OBJECT (pipeline));
+ pipeline = NULL;
+ }
+ if(source) {
+ gst_object_unref (GST_OBJECT (source));
+ source = NULL;
+ }
+ if(encoder) {
+ gst_object_unref (GST_OBJECT (encoder));
+ encoder = NULL;
+ }
+ if(mux) {
+ gst_object_unref (GST_OBJECT (mux));
+ mux = NULL;
+ }
+ if(sink) {
+ gst_object_unref (GST_OBJECT (sink));
+ sink = NULL;
+ }
+ RLOGE ("[GSM]One element could not be created. Exiting");
+ return -1;
+ }
+
+ gst_bin_add_many (GST_BIN (pipeline), source, encoder, mux, sink, NULL);
+ gst_element_link_many (source, encoder, mux, sink, NULL);
+
+ pipeline_element = pipeline;
+ gst_status = 1; //initial done
+ RLOGD("[GSM]GSM Init Done!");
+ return 0;
+}
+static int GSM_Start(void)
+{
+ RLOGD("[GSM]GSM Start start!");
+ if(gst_status == 2)
+ return 0;
+
+ if(gst_status == 1 || gst_status ==3) {
+ GstStateChangeReturn ret = gst_element_set_state (pipeline_element, GST_STATE_PLAYING);
+
+ RLOGD("[GSM]Running... return: %d", ret);
+ //g_main_loop_run (gst_loop);
+ gst_status = 2; //start done
+ } else {
+ return -1;
+ }
+ RLOGD("[GSM]GSM Start End!");
+ return 0;
+}
+
+static int GSM_Stop()
+{
+ RLOGD("[GSM]GSM Stop Start!");
+ if (gst_status == 4)
+ return 0;
+
+ if(gst_status == 2 || gst_status == 3) {
+ /* Out of the main loop, clean up nicely */
+ gboolean isSend = gst_element_send_event (pipeline_element, gst_event_new_eos ());
+ GstStateChangeReturn ret = gst_element_set_state (pipeline_element, GST_STATE_NULL);
+ RLOGD("[GSM]Returned, stopping playback. ret: %d, isSend: %d", ret, isSend);
+ gst_status = 4;
+ } else {
+ return -1;
+ }
+ RLOGD("[GSM]GSM Stop End!");
+ return 0;
+}
+static int GSM_Close()
+{
+ RLOGD("[GSM]Deleting pipeline");
+ gst_object_unref (GST_OBJECT (pipeline_element));
+ gst_deinit ();
+ gst_status = 0;
+ RLOGD("[GSM]GSM Close Done!");
+ return 0;
+}
+int lynq_incall_record(char* file_path)
+{
+ RLOGD("start GSM!");
+ if(-1 != GSM_Init(file_path) && -1 != GSM_Start()) {
+ inCallRecordMode = 1;
+ RLOGW("inCallRecord Start OK!");
+ }else{
+ inCallRecordMode = 0;
+ return 1;
+ RLOGW("[error],inCallRecord Start fail!");
+ }
+
+ return 0;
+}
+int lynq_stop_record()
+{
+ RLOGD("After Handup, stop record! Before Record is %s",inCallRecordMode ? "Enable" : "Disable");
+ if (inCallRecordMode == 1) {
+ if(!(-1 != GSM_Stop() && -1 != GSM_Close()))
+ RLOGW("[error],inCallRecord fail!");
+
+ inCallRecordMode = 0;
+ /*From GSM report stop_record to PulseAudio send record_off need 15ms. so after stop record delay 30ms*/
+ usleep(30*1000);
+ return 1;
+ }
+ return 0;
+}
+
+static int mixer_set_mute(int path, int value)
+{
+ RLOGD("mixer_set_mute path: %d , value: %d", path, value);
+ int ret;
+ /* DL:0 UL:1 */
+ if (path == 0) {
+ ret = set_mixer_ctrl_value_int(g_DL_mute_name, value);
+ } else {
+ ret = set_mixer_ctrl_value_int(g_UL_mute_name, value);
+ }
+ if (ret) {
+ RLOGE("set_mixer_ctrl_volume_value_int err: %d", ret);
+ }
+ return ret;
+}
+
+static long int mixer_get_mute(int path)
+{
+ long int is_mute;
+
+ /* DL:0 UL:1 */
+ if (path == 0) {
+ is_mute = get_mixer_ctrl_value_int(g_DL_mute_name);
+ RLOGD("The ctrl \"%s\" is set to %d", g_DL_mute_name, is_mute);
+ } else {
+ is_mute = get_mixer_ctrl_value_int(g_UL_mute_name);
+ RLOGD("The ctrl \"%s\" is set to %d", g_UL_mute_name, is_mute);
+ }
+
+ return is_mute;
+}
+ int lynq_set_call_mute(int mute) {
+ RLOGD("setCallMute: %d", mute);
+ return mixer_set_mute(1, (mute ? 1: 0));
+}
+
+int lynq_get_call_mute() {
+ long int cc_mute = mixer_get_mute(1);
+ RLOGD("getCallMute: %d", cc_mute);
+ return cc_mute;
+}
+
+
+void lynq_reset_mute() {
+ if (lynq_get_call_mute() > 0) {
+ lynq_set_call_mute(0);
+ }
+}
+
+