| | |
| | | onStartUsbRecord = { startUsbRecord() }, |
| | | onStopUsbRecord = { stopUsbRecord() }, |
| | | onStartUsbPush = { startUsbPush() }, |
| | | onStopUsbPush = { stopUsbPush() } |
| | | onStopUsbPush = { stopUsbPush() }, |
| | | onStartP2Push = { startP2Push() }, |
| | | onStopP2Push = { stopP2Push() }, |
| | | onStartP2Record = { startP2Record() }, |
| | | onStopP2Record = { stopP2Record() } |
| | | ) |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | try { |
| | | mediaAidlInterface?.stopMedia() |
| | | val mediaArgu = MediaArgu().apply { |
| | | isPush = false |
| | | isUsedOutCamera = false // Android 内置摄像头 |
| | | usbCameraId = 0 // Android 相机,usbCameraId 为 0 |
| | | } |
| | | mediaAidlInterface?.stopMedia(mediaArgu) |
| | | Timber.d("Stopped Android camera record") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error stopping Android record") |
| | |
| | | val mediaArgu = MediaArgu().apply { |
| | | isPush = false |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | usbCameraId = 1 // P1 USB 摄像头 |
| | | codeRate = 0 |
| | | frameRate = 0 |
| | | m_screen = MediaArgu.ScreenSolution(640, 480) // 默认分辨率 |
| | |
| | | |
| | | mediaAidlInterface?.registerCallback(callback) |
| | | mediaAidlInterface?.startMedia(mediaArgu) |
| | | Timber.d("Started USB camera record") |
| | | Timber.d("Started USB camera record (P1)") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error starting USB record") |
| | | } |
| | |
| | | } |
| | | |
| | | try { |
| | | mediaAidlInterface?.stopMedia() |
| | | Timber.d("Stopped USB camera record") |
| | | val mediaArgu = MediaArgu().apply { |
| | | isPush = false |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | usbCameraId = 1 // P1 USB 摄像头 |
| | | } |
| | | mediaAidlInterface?.stopMedia(mediaArgu) |
| | | Timber.d("Stopped USB camera record (P1)") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error stopping USB record") |
| | | } |
| | |
| | | |
| | | try { |
| | | val mediaArgu = MediaArgu().apply { |
| | | usbCameraId = 1 // P1 USB 摄像头 |
| | | isPush = true |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | codeRate = 0 |
| | |
| | | |
| | | mediaAidlInterface?.registerCallback(callback) |
| | | mediaAidlInterface?.startMedia(mediaArgu) |
| | | Timber.d("Started USB camera push") |
| | | Timber.d("Started USB camera push (P1)") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error starting USB push") |
| | | } |
| | |
| | | } |
| | | |
| | | try { |
| | | mediaAidlInterface?.stopMedia() |
| | | Timber.d("Stopped USB camera push") |
| | | val mediaArgu = MediaArgu().apply { |
| | | usbCameraId = 1 // P1 USB 摄像头 |
| | | isPush = true |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | } |
| | | mediaAidlInterface?.stopMedia(mediaArgu) |
| | | Timber.d("Stopped USB camera push (P1)") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error stopping USB push") |
| | | } |
| | | } |
| | | |
| | | private fun startP2Push() { |
| | | if (mediaAidlInterface == null) { |
| | | Timber.w("Service not bound, cannot start P2 push") |
| | | return |
| | | } |
| | | |
| | | try { |
| | | val mediaArgu = MediaArgu().apply { |
| | | usbCameraId = 2 // P2 USB 摄像头 |
| | | isPush = true |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | codeRate = 0 |
| | | frameRate = 0 |
| | | m_screen = MediaArgu.ScreenSolution(640, 480) // 默认分辨率 |
| | | url = "rtmp://192.168.16.143/live/livestream" // TODO: 需要设置实际的推流地址 |
| | | userName = "" |
| | | pwd = "" |
| | | } |
| | | |
| | | mediaAidlInterface?.registerCallback(callback) |
| | | mediaAidlInterface?.startMedia(mediaArgu) |
| | | Timber.d("Started P2 USB camera push") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error starting P2 push") |
| | | } |
| | | } |
| | | |
| | | private fun stopP2Push() { |
| | | if (mediaAidlInterface == null) { |
| | | Timber.w("Service not bound, cannot stop P2 push") |
| | | return |
| | | } |
| | | |
| | | try { |
| | | val mediaArgu = MediaArgu().apply { |
| | | usbCameraId = 2 // P2 USB 摄像头 |
| | | isPush = true |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | } |
| | | mediaAidlInterface?.stopMedia(mediaArgu) |
| | | Timber.d("Stopped P2 USB camera push") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error stopping P2 push") |
| | | } |
| | | } |
| | | |
| | | private fun startP2Record() { |
| | | if (mediaAidlInterface == null) { |
| | | Timber.w("Service not bound, cannot start P2 record") |
| | | return |
| | | } |
| | | |
| | | try { |
| | | val mediaArgu = MediaArgu().apply { |
| | | isPush = false |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | usbCameraId = 2 // P2 USB 摄像头 |
| | | codeRate = 0 |
| | | frameRate = 0 |
| | | m_screen = MediaArgu.ScreenSolution(640, 480) // 默认分辨率 |
| | | recordTime = 0 |
| | | tfCardFlag = 0 // 内部存储 |
| | | } |
| | | |
| | | mediaAidlInterface?.registerCallback(callback) |
| | | mediaAidlInterface?.startMedia(mediaArgu) |
| | | Timber.d("Started P2 USB camera record") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error starting P2 record") |
| | | } |
| | | } |
| | | |
| | | private fun stopP2Record() { |
| | | if (mediaAidlInterface == null) { |
| | | Timber.w("Service not bound, cannot stop P2 record") |
| | | return |
| | | } |
| | | |
| | | try { |
| | | val mediaArgu = MediaArgu().apply { |
| | | isPush = false |
| | | isUsedOutCamera = true // USB 摄像头 |
| | | usbCameraId = 2 // P2 USB 摄像头 |
| | | } |
| | | mediaAidlInterface?.stopMedia(mediaArgu) |
| | | Timber.d("Stopped P2 USB camera record") |
| | | } catch (e: RemoteException) { |
| | | Timber.e(e, "Error stopping P2 record") |
| | | } |
| | | } |
| | | |
| | |
| | | onStartUsbRecord: () -> Unit, |
| | | onStopUsbRecord: () -> Unit, |
| | | onStartUsbPush: () -> Unit, |
| | | onStopUsbPush: () -> Unit |
| | | onStopUsbPush: () -> Unit, |
| | | onStartP2Push: () -> Unit, |
| | | onStopP2Push: () -> Unit, |
| | | onStartP2Record: () -> Unit, |
| | | onStopP2Record: () -> Unit |
| | | ) { |
| | | Column( |
| | | modifier = Modifier.fillMaxSize() |
| | |
| | | |
| | | Divider(modifier = Modifier.padding(vertical = 8.dp)) |
| | | |
| | | // 按钮 7: 开始 USB 推流 |
| | | // 按钮 7: 开始 USB 推流 (P1) |
| | | Button( |
| | | onClick = onStartUsbPush, |
| | | modifier = Modifier.fillMaxWidth(), |
| | | enabled = isServiceBound |
| | | ) { |
| | | Text("7. 开始 USB 推流") |
| | | Text("7. 开始 USB 推流 (P1)") |
| | | } |
| | | |
| | | // 按钮 8: 结束 USB 推流 |
| | | // 按钮 8: 结束 USB 推流 (P1) |
| | | Button( |
| | | onClick = onStopUsbPush, |
| | | modifier = Modifier.fillMaxWidth(), |
| | | enabled = isServiceBound |
| | | ) { |
| | | Text("8. 结束 USB 推流") |
| | | Text("8. 结束 USB 推流 (P1)") |
| | | } |
| | | |
| | | Divider(modifier = Modifier.padding(vertical = 8.dp)) |
| | | |
| | | // 按钮 9: 开始 P2 USB 推流 |
| | | Button( |
| | | onClick = onStartP2Push, |
| | | modifier = Modifier.fillMaxWidth(), |
| | | enabled = isServiceBound |
| | | ) { |
| | | Text("9. 开始 P2 USB 推流") |
| | | } |
| | | |
| | | // 按钮 10: 结束 P2 USB 推流 |
| | | Button( |
| | | onClick = onStopP2Push, |
| | | modifier = Modifier.fillMaxWidth(), |
| | | enabled = isServiceBound |
| | | ) { |
| | | Text("10. 结束 P2 USB 推流") |
| | | } |
| | | |
| | | Divider(modifier = Modifier.padding(vertical = 8.dp)) |
| | | |
| | | // 按钮 11: 开始 P2 USB 录像 |
| | | Button( |
| | | onClick = onStartP2Record, |
| | | modifier = Modifier.fillMaxWidth(), |
| | | enabled = isServiceBound |
| | | ) { |
| | | Text("11. 开始 P2 USB 录像") |
| | | } |
| | | |
| | | // 按钮 12: 结束 P2 USB 录像 |
| | | Button( |
| | | onClick = onStopP2Record, |
| | | modifier = Modifier.fillMaxWidth(), |
| | | enabled = isServiceBound |
| | | ) { |
| | | Text("12. 结束 P2 USB 录像") |
| | | } |
| | | |
| | | Spacer(modifier = Modifier.height(12.dp)) |