I'm trying to control via DBus multiple instances of omxplayer. This is the code I currently use to control the application:
QDBusConnection *m_dbus = new QDBusConnection(QDBusConnection::sessionBus());
m_dbus->connectToBus("/tmp/omxplayerdbus.root", "org.mpris.MediaPlayer2.omxplayer");
// ...
QString dest = "org.mpris.MediaPlayer2.omxplayer";
QString path = "/org/mpris/MediaPlayer2";
QString interface = "org.mpris.MediaPlayer2.Player";
QString name = "Action";
QDBusMessage msg = QDBusMessage::createMethodCall(dest, path, interface, name);
msg.setArguments(QList<QVariant>() << 16);
m_dbus->send(msg);
/tmp/omxplayerdbus.root contains the address and it's created in this way:
DBUS_CMD="dbus-daemon --fork --print-address 5 --print-pid 6 --session"
OMXPLAYER_DBUS_ADDR="/tmp/omxplayerdbus.${USER:-root}"
OMXPLAYER_DBUS_PID="/tmp/omxplayerdbus.${USER:-root}.pid"
exec 5> "$OMXPLAYER_DBUS_ADDR"
exec 6> "$OMXPLAYER_DBUS_PID"
$DBUS_CMD
DBUS_SESSION_BUS_ADDRESS=`cat $OMXPLAYER_DBUS_ADDR`
DBUS_SESSION_BUS_PID=`cat $OMXPLAYER_DBUS_PID`
export DBUS_SESSION_BUS_ADDRESS
export DBUS_SESSION_BUS_PID
OMXPLAYER_DIR="/usr/bin"
OMXPLAYER_BIN="$OMXPLAYER_DIR/omxplayer.bin"
$OMXPLAYER_BIN "$@"
Now I want to start another instance of omxplayer and I want to control it from DBus.
I need to fork the dbus-daemon each time providing different addresses and in my application I have to connect to the related bus? In this case, I have to kill the forked process when the associated omxplayer will end?