Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPCamera #95

Open
Brunz opened this issue Dec 13, 2019 · 12 comments
Open

IPCamera #95

Brunz opened this issue Dec 13, 2019 · 12 comments

Comments

@Brunz
Copy link

Brunz commented Dec 13, 2019

Could you create an IPCamera type accessory? I didn't understand how to do it

@Bouke
Copy link
Owner

Bouke commented Dec 15, 2019

That's a good question actually. It seems we don't have the proper accessories / services / characteristics to do that. Those types are generated from a framework, but on my machine (latest Catalina), those types aren't present or we're not looking in the right place.

@Brunz
Copy link
Author

Brunz commented Dec 15, 2019

Actually there are some in the framework, but I couldn't understand why they are not imported by hap-update. I created them manually, I see the video window on homekit, but I have problems starting the video. Maybe I don't correctly insert the bytes (tlv8).
Sorry for my English.

@Brunz
Copy link
Author

Brunz commented Dec 16, 2019

This is an example of what is found in "plain-metadata.config" and which is not imported:
<key>camera-rtp-stream-management</key> <dict> <key>Characteristics</key> <dict> <key>Optional</key> <array> <string>active</string> </array> <key>Required</key> <array> <string>selected-stream-configuration</string> <string>setup-stream-endpoint</string> <string>streaming-status</string> <string>supported-audio-stream-configuration</string> <string>supported-rtp-configuration</string> <string>supported-video-stream-configuration</string> </array> </dict> <key>DefaultDescription</key> <string>Camera Stream Management</string> <key>LocalizationKey</key> <string></string> <key>ShortUUID</key> <string>00000110</string> </dict>

@Bouke
Copy link
Owner

Bouke commented Dec 16, 2019

We only emit the characteristics that are actually in use by a service. You can remove && whitelistedCharacteristics.contains(name) on this line, so at least you get all the characteristics:

if !blacklistedCharacteristics.contains(name) && whitelistedCharacteristics.contains(name) {

However you still wouldn't have a pre-made accessory and service, as those are not listed in that framework. Can you share what your configuration looks like so far, to get them listed in the Home app?

@Brunz
Copy link
Author

Brunz commented Dec 16, 2019

Great Bouke!
"camera-rtp-stream-management" is a Service and YES this is in the "BlacklistFromApplications".
I make a change to the inspector and try to import again.

The test implementation is attached to the message.
Camera.swift.zip

@Brunz
Copy link
Author

Brunz commented Dec 16, 2019

ok, I have removed camera-rtp-stream-management from blacklistAppServices

if var index = blacklistAppServices.firstIndex(where: {$0 == "camera-rtp-stream-management"}){ blacklistAppServices.remove(at: index) }

..and now I have Service and Characteristics into Generated.swift

After I modified the file "CharacteristicValueType" in this way:

extension Data: CharacteristicValueType, JSONValueTypeConvertible { public init?(value: Any) { //fatalError("How does deserialization of Data work?") if let v = value as? String, let vd = Data(base64Encoded: v){ self = vd } return nil } static public let format = CharacteristicFormat.data public var jsonValueType: JSONValueType { //fatalError("How does serialization of Data work?") return self.base64EncodedString() } }

and now I'm at the point of before :) But it's much cleaner

@Bouke
Copy link
Owner

Bouke commented Dec 18, 2019

Out of curiosity; what does your code look like now to initialize the camera accessory?

@Brunz
Copy link
Author

Brunz commented Dec 18, 2019

this:
acc.append(Accessory.RTPCamera(info: Service.Info(name: "Camera", serialNumber: "00012")))
Append the accessory "RTPCamera" in Device.accessories array

And intercept "resource" in router func, for send camera snapshot to controller:
func router(_ routes: [Route]) -> Responder {
return { connection, request in
if(request.url.path == "/resource"){
...

The preview is ok now, the streaming rtsp still no.
Schermata 2019-12-18 alle 21 17 58

@Brunz
Copy link
Author

Brunz commented Dec 19, 2019

But maybe I make some mistakes, because the controller should send me a response to the configuration of the Camera, but I don't see. If you want I can send the project, but it is compiled only on iOS.

@joshsnelling
Copy link

@Brunz Did you ever get this to work?

@Brunz
Copy link
Author

Brunz commented May 2, 2020

Hi @joshsnelling ,

I implemented all the missing piece of protocol but I was unable to send the video in the correct format. I have also tried using ffmpeg for iOS to configure RTS streaming, but there are too many properties to configure and I am not an expert.

@poldueta
Copy link

@Brunz Hi! Any progress with camera accessory implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants