Menu
andipanda.dev

CaRaBack: CaRadio Is No Longer Tied to Raspberry Pi

In the previous article, I described how I managed to establish a connection with an iPhone, complete the necessary authentication steps, and obtain a decrypted H.264 video stream directly from the phone.

My first test was fairly simple: I saved the received data to a file, transferred it to a Windows computer, and confirmed that the video could actually be played.

This was an important result, but I was still a long way from having a fully working CarPlay system.

Now a logical question arose: what should I do with the video stream next?

Of course, I could have started decoding and displaying the video directly on the Raspberry Pi. But first, I wanted to try a different approach — streaming the video over a network.

First Network Experiments

CaRaBack was running on a Raspberry Pi 3B+, while I used a Windows laptop as the second device.

At this stage, I did not have my own graphical client yet.

The goal was to transmit the received H.264 stream over the network and play it on the laptop.

For testing, I used FFmpeg.

This allowed me to focus on transmitting the video data without getting distracted by developing a graphical interface or my own decoder.

The first experiments were successful.

The video stream CaRaBack received from the iPhone could be transmitted over the network and played on another computer.

It was after these tests that an idea began to take shape — one that would eventually define the project's architecture.

Separation of Responsibilities

Initially, I did not set out to run CarPlay on two separate devices.

I was also considering a setup where both CaRaBack and the graphical interface would run on the same Raspberry Pi, communicating through the loopback interface.

But successfully streaming video to the laptop demonstrated that the physical location of these components did not really matter.

If the video stream could be sent to another device, why not make this kind of communication the foundation of the architecture?

That was how the idea of separating responsibilities gradually emerged.

CaRaBack would become a standalone server, fully responsible for communicating with the iPhone.

Its responsibilities would include connecting to the phone, authentication, handling the necessary protocols, receiving and processing audio and video data, and forwarding control commands back to the phone.

The user interface, meanwhile, would become a separate client application.

It would no longer need to handle the details of connecting to an iPhone or implementing CarPlay protocols.

All it needed to do was connect to CaRaBack, receive the required data, and send user actions back to the server.

Both applications could run either on different devices or on the same computer.

This separation opened up many more possibilities for the project's future development.

But first, I needed to implement proper communication between the server and the client.

A Custom IPC Protocol

I started developing my own IPC protocol for communication between CaRaBack and the graphical application.

The initial FFmpeg experiments had proven that video streaming worked, but that alone was not enough for a fully functional CarPlay system.

Now I needed to transmit not only video but also other information required by the client application.

In addition, communication had to work in both directions.

The server sends playback data to the client, while the client sends user actions back to the server.

In this way, CaRaBack became an intermediary between the iPhone and the graphical interface, hiding the details of the CarPlay protocols from the latter.

Developing the custom protocol required changes to both parts of the project.

On the CaRaBack side, I added the logic needed to communicate with the client application. On the GUI side, I implemented the corresponding connection and data-handling mechanisms.

Now I could move beyond FFmpeg experiments and start working on my own application.

A C++ and SDL Client

I chose C++ and SDL for developing the graphical client.

Windows became my primary development platform.

This was mainly a matter of convenience. Developing a graphical application, debugging it, and testing changes on a laptop was much easier than constantly running everything directly on the Raspberry Pi.

At the same time, I did not want to tie the client to Windows.

That is why the project used CMake from the beginning and was designed with the possibility of building it for other platforms.

This approach also preserved the option of running both the server and client on a single Raspberry Pi in the future.

The only difference would be where the graphical application connected: to a local server through the loopback interface or to CaRaBack running on another device over the network.

The client gradually took over the role of the user interface for interacting with the phone.

Naturally, the first task was video playback.

Instead of using FFmpeg as a separate tool, I now needed to receive the stream through my custom IPC protocol and display it within the client application.

Once this part was implemented, I could see the CarPlay interface in my own window on Windows.

But at that point, it was still just an image.

To make the system genuinely useful, I needed to add a way to control the phone.

Sending Touch Input Back to the Phone

The next stage was implementing CarPlay controls.

Simply receiving and playing a video stream is not enough to properly test the system.

User actions also need to be sent back to the iPhone.

In the client application, I reused the existing user input handling code from the first version of CaRadio, adapting it for the new SDL-based client.

During testing on Windows, mouse events were handled as touchscreen input.

Information about user actions was then transmitted over the network through my custom IPC protocol to CaRaBack.

The server, in turn, converted the received data into the appropriate commands for communicating with the iPhone.

This established full two-way interaction.

Now I could do more than just watch the CarPlay interface. I could interact with it: select interface elements, launch applications, and control their behavior.

This was another important milestone.

The system was gradually moving beyond an experiment in receiving a video stream and becoming a working CarPlay implementation.

However, one major task still remained — audio.

Music and Additional Audio Streams

I left audio support for the final stage.

CarPlay transmits more than just video. A fully functional system also needs to receive and play audio data.

And there is an important detail here.

Music and additional sounds are not transmitted as a single combined audio stream.

Besides the music channel, there is a separate channel for navigation prompts and other additional sounds.

The way these sounds were handled was actually one of the reasons I had started investigating the possibility of implementing CarPlay myself.

In CaRadio v1, using the Carlinkit adapter, I had already encountered a problem detecting when a spoken navigation instruction ended.

At the time, I had to use a timeout-based workaround.

Now that communication with the iPhone was handled directly by CaRaBack, I could work with the corresponding audio streams in my own implementation.

I started by implementing music transmission and playback.

After that, I moved on to the additional audio channel used for spoken navigation instructions and other system sounds.

As with video, the audio data had to be received by CaRaBack, transmitted to the client application, and played back.

Implementing audio also required changes beyond the client application.

CaRaBack itself had to be extended to process the relevant data correctly and communicate with the iPhone.

That is why development of the graphical client and the server progressed in parallel.

Without the ability to test video playback, touch input forwarding, and audio handling, it would have been impossible to bring CaRaBack to a fully working state.

Bringing Everything Together

Gradually, I managed to combine all the necessary components.

CaRaBack established a connection with the iPhone, completed the required authentication steps, and handled CarPlay data exchange.

The client application connected to the server through my custom IPC protocol.

The video stream was transmitted over the network and displayed in the graphical interface.

User actions were sent back to the iPhone through CaRaBack.

Music and additional sounds were also transmitted to the client for playback.

The result was a working system with separate server and client components.

Most importantly, the user interface was no longer tied to the device running CaRaBack.

The Raspberry Pi could handle communication with the iPhone, while display and control could take place on another computer.

If necessary, both applications could still run on the same platform.

For me, this was one of the most important achievements of the development process.

CaRaBack was no longer a collection of separate experiments involving MFi, Bluetooth, and AirPlay.

It had become a standalone CarPlay server component that a separate client application could communicate with.

A Break Before the Next Stage

After implementing video streaming, controls, and audio playback, I put the project aside for a while.

The main problem that had started everything was solved.

I had managed to eliminate the need for Carlinkit as a software intermediary between the iPhone and my own application.

But the story did not end there.

When I later returned to the project, my attention shifted back to the Carlinkit U2W Mini.

This time, I was interested in more than just the MFi chip I had found inside.

I decided to investigate the device itself, its hardware, and the operating system installed on it.

That marked the beginning of the next stage of experiments — disassembling the adapter, searching for a way to access Linux, and exploring what was happening inside Carlinkit.

I will cover that in the next article.