Dana
2025-11-30 ce6059a78372f8c362cfe2c96c019540ca1d96b8
1.加一个sim卡号字段
3个文件已修改
23 ■■■■■ 已修改文件
app/src/main/aidl/com/anyun/h264/IH264EncodeService.aidl 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/anyun/h264/H264EncodeService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/anyun/h264/service/H264EncodeServiceClient.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/aidl/com/anyun/h264/IH264EncodeService.aidl
@@ -10,8 +10,8 @@
    /**
     * 控制H264编码
     * @param action 操作类型:0-开启h264文件写入,1-停止h264编码并停止写入文件,2-开启网络推送h264(不写入文件),3-停止h264编码并停止网络推送
     * @param jsonConfig JSON格式的配置参数,包含:ip(服务器IP)、port(服务器端口)、width(视频宽度)、height(视频高度)、framerate(帧率)
     *                  示例:{"ip":"192.168.1.100","port":8888,"width":640,"height":480,"framerate":25}
     * @param jsonConfig JSON格式的配置参数,包含:ip(服务器IP)、port(服务器端口)、width(视频宽度)、height(视频高度)、framerate(帧率)、simPhone(SIM卡号)
     *                  示例:{"ip":"192.168.1.100","port":8888,"width":640,"height":480,"framerate":25,"simPhone":"013120122580"}
     *                  如果action为1或3(停止操作),此参数可为空或null
     * @return 0-成功,1-失败
     */
app/src/main/java/com/anyun/h264/H264EncodeService.java
@@ -93,6 +93,7 @@
        int width;
        int height;
        int framerate;
        String simPhone;
        
        // 从JSON解析配置
        static EncodeConfig fromJson(String jsonConfig) throws JSONException {
@@ -104,6 +105,7 @@
                config.framerate = DEFAULT_FRAME_RATE;
                config.ip = null;
                config.port = 0;
                config.simPhone = null;
                return config;
            }
            
@@ -113,6 +115,7 @@
            config.framerate = json.optInt("framerate", DEFAULT_FRAME_RATE);
            config.ip = json.optString("ip", null);
            config.port = json.optInt("port", 0);
            config.simPhone = json.optString("simPhone", null);
            
            return config;
        }
@@ -121,7 +124,7 @@
    /**
     * 控制H264编码
     * @param action 操作类型:0-开启h264文件写入,1-停止h264编码并停止写入文件,2-开启网络推送h264(不写入文件),3-停止h264编码并停止网络推送
     * @param jsonConfig JSON格式的配置参数,包含:ip、port、width、height、framerate
     * @param jsonConfig JSON格式的配置参数,包含:ip、port、width、height、framerate、simPhone
     * @return 0-成功,1-失败
     */
    private synchronized int controlEncode(int action, String jsonConfig) {
@@ -135,7 +138,8 @@
                try {
                    config = EncodeConfig.fromJson(jsonConfig);
                    Log.d(TAG, "Parsed config - width: " + config.width + ", height: " + config.height + 
                            ", framerate: " + config.framerate + ", ip: " + config.ip + ", port: " + config.port);
                            ", framerate: " + config.framerate + ", ip: " + config.ip + ", port: " + config.port +
                            ", simPhone: " + config.simPhone);
                } catch (JSONException e) {
                    Log.e(TAG, "Failed to parse JSON config: " + jsonConfig, e);
                    return 1; // 失败
@@ -253,9 +257,10 @@
            h264Encoder.setEnableNetworkTransmission(true);
            h264Encoder.setServerAddress(config.ip, config.port);
            
            // 设置协议参数(使用默认值,可根据需要从配置中添加)
            // TODO: 如果需要在JSON配置中添加simCardNumber和logicalChannelNumber,可以在这里解析
            h264Encoder.setProtocolParams("013120122580", (byte)1);
            // 设置协议参数(使用配置中的simPhone,如果未提供则使用默认值)
            String simPhone = config.simPhone != null && !config.simPhone.trim().isEmpty()
                    ? config.simPhone : "013120122580";
            h264Encoder.setProtocolParams(simPhone, (byte)1);
            
            // 初始化并启动(使用配置中的分辨率)
            int[] resolution = {width, height};
app/src/main/java/com/anyun/h264/service/H264EncodeServiceClient.java
@@ -149,8 +149,8 @@
    /**
     * 控制H264编码
     * @param action 操作类型:0-开启h264文件写入,1-停止h264编码并停止写入文件,2-开启网络推送h264(不写入文件),3-停止h264编码并停止网络推送
     * @param jsonConfig JSON格式的配置参数,包含:ip(服务器IP)、port(服务器端口)、width(视频宽度)、height(视频高度)、framerate(帧率)
     *                  示例:{"ip":"192.168.1.100","port":8888,"width":640,"height":480,"framerate":25}
     * @param jsonConfig JSON格式的配置参数,包含:ip(服务器IP)、port(服务器端口)、width(视频宽度)、height(视频高度)、framerate(帧率)、simPhone(SIM卡号)
     *                  示例:{"ip":"192.168.1.100","port":8888,"width":640,"height":480,"framerate":25,"simPhone":"013120122580"}
     *                  如果action为1或3(停止操作),此参数可为null
     * @return 0-成功,1-失败
     */