[chromecast] First building blocks for supporting ChromeCast

This commit is contained in:
ejurgensen 2016-01-17 20:59:16 +01:00
parent 62eb1a067d
commit 4c887ba7bb
12 changed files with 1555 additions and 18 deletions

View File

@ -182,6 +182,15 @@ AS_IF([test "x$enable_lastfm" = "xyes"], [
])
AM_CONDITIONAL(COND_LASTFM, [test "x$enable_lastfm" = "xyes"])
dnl ChromeCast support with libprotobuf-c
AC_ARG_ENABLE(chromecast, AS_HELP_STRING([--enable-chromecast], [enable ChromeCast support (default=no)]))
AS_IF([test "x$enable_chromecast" = "xyes"], [
AC_DEFINE(CHROMECAST, 1, [Define to 1 to enable Chromecast support])
PKG_CHECK_MODULES(LIBPROTOBUF_C, [ libprotobuf-c ], , [ LDFLAGS="${LDFLAGS} -lprotobuf-c" ])
PKG_CHECK_MODULES(GNUTLS, [ gnutls ])
])
AM_CONDITIONAL(COND_CHROMECAST, [test "x$enable_chromecast" = "xyes"])
dnl MPD support
AC_ARG_ENABLE(mpd, AS_HELP_STRING([--disable-mpd], [disable MPD client protocol support (default=no)]))
AS_IF([test "x$enable_mpd" != "xno"], [

View File

@ -13,6 +13,10 @@ if COND_LASTFM
LASTFM_SRC=lastfm.c lastfm.h
endif
if COND_CHROMECAST
CHROMECAST_SRC=cast.h cast.c cast_channel.pb-c.h cast_channel.pb-c.c
endif
if COND_MPD
MPD_SRC=mpd.c mpd.h
endif
@ -60,14 +64,14 @@ forked_daapd_CFLAGS = \
@ZLIB_CFLAGS@ @AVAHI_CFLAGS@ @SQLITE3_CFLAGS@ @LIBAV_CFLAGS@ \
@CONFUSE_CFLAGS@ @MINIXML_CFLAGS@ @LIBPLIST_CFLAGS@ \
@LIBGCRYPT_CFLAGS@ @GPG_ERROR_CFLAGS@ @ALSA_CFLAGS@ @SPOTIFY_CFLAGS@ \
@LIBCURL_CFLAGS@
@LIBCURL_CFLAGS@ @LIBPROTOBUF_C_CFLAGS@ @GNUTLS_CFLAGS@
forked_daapd_LDADD = -lrt \
@ZLIB_LIBS@ @AVAHI_LIBS@ @SQLITE3_LIBS@ @LIBAV_LIBS@ \
@CONFUSE_LIBS@ @LIBEVENT_LIBS@ \
@MINIXML_LIBS@ @ANTLR3C_LIBS@ @LIBPLIST_LIBS@ \
@LIBGCRYPT_LIBS@ @GPG_ERROR_LIBS@ @ALSA_LIBS@ @LIBUNISTRING@ @SPOTIFY_LIBS@ \
@LIBCURL_LIBS@
@LIBCURL_LIBS@ @LIBPROTOBUF_C_LIBS@ @GNUTLS_LIBS@
forked_daapd_SOURCES = main.c \
db.c db.h \
@ -105,6 +109,7 @@ forked_daapd_SOURCES = main.c \
evrtsp/rtsp.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h \
$(SPOTIFY_SRC) \
$(LASTFM_SRC) \
$(CHROMECAST_SRC) \
$(MPD_SRC) \
listener.c listener.h

465
src/cast.c Normal file
View File

@ -0,0 +1,465 @@
/*
* Copyright (C) 2015-2016 Espen Jürgensen <espenjurgensen@gmail.com>
*
* TODO Credits
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <endian.h>
#include <gnutls/gnutls.h>
#include <event2/event.h>
#include "logger.h"
#include "cast_channel.pb-c.h"
#include "cast.h"
// Number of bytes to request from TLS connection
#define MAX_BUF 4096
// CA file location (not very portable...?)
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
// Namespaces
#define NS_CONNECTION "urn:x-cast:com.google.cast.tp.connection"
#define NS_RECEIVER "urn:x-cast:com.google.cast.receiver"
#define NS_HEARTBEAT "urn:x-cast:com.google.cast.tp.heartbeat"
#define NS_MEDIA "urn:x-cast:com.google.cast.media"
struct cast_session
{
struct event *ev;
gnutls_session_t tls_session;
char *devname;
char *address;
unsigned short port;
int volume;
int server_fd;
/* Do not dereference - only passed to the status cb */
struct raop_device *dev;
raop_status_cb status_cb;
struct cast_session *next;
};
enum cast_msg_type
{
UNKNOWN,
PING,
PONG,
CONNECT,
CLOSE,
GET_STATUS,
LAUNCH,
MEDIA_CONNECT,
MEDIA_LOAD,
MEDIA_GET_STATUS,
MEDIA_PLAY,
MEDIA_STOP,
};
/* From player.c */
extern struct event_base *evbase_player;
/* Globals */
static gnutls_certificate_credentials_t tls_credentials;
static struct cast_session *sessions;
static int
tcp_connect(const char *address, unsigned int port, int family)
{
union sockaddr_all sa;
int fd;
int len;
int ret;
fd = socket(family, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (fd < 0)
{
DPRINTF(E_LOG, L_CAST, "Could not create socket: %s\n", strerror(errno));
return -1;
}
switch (family)
{
case AF_INET:
sa.sin.sin_port = htons(port);
ret = inet_pton(AF_INET, address, &sa.sin.sin_addr);
len = sizeof(sa.sin);
break;
case AF_INET6:
sa.sin6.sin6_port = htons(port);
ret = inet_pton(AF_INET6, address, &sa.sin6.sin6_addr);
len = sizeof(sa.sin6);
break;
default:
DPRINTF(E_WARN, L_CAST, "Unknown family %d\n", family);
close(fd);
return -1;
}
if (ret <= 0)
{
DPRINTF(E_LOG, L_CAST, "Device address not valid (%s)\n", address);
close(fd);
return -1;
}
sa.ss.ss_family = family;
ret = connect(fd, &sa.sa, len);
if (ret < 0)
{
DPRINTF(E_LOG, L_CAST, "connect() to [%s]:%u failed: %s\n", address, port, strerror(errno));
close(fd);
return -1;
}
return fd;
}
static void
tcp_close (int fd)
{
/* no more receptions */
shutdown(fd, SHUT_RDWR);
close(fd);
}
enum cast_msg_type
cast_msg_unpack(const uint8_t *data, size_t len)
{
enum cast_msg_type type;
Extensions__CoreApi__CastChannel__CastMessage *reply;
// char *val;
reply = extensions__core_api__cast_channel__cast_message__unpack(NULL, len, data);
DPRINTF(E_DBG, L_CAST, "RX %d %s %s %s %s\n", len, reply->source_id, reply->destination_id, reply->namespace_, reply->payload_utf8);
type = UNKNOWN;
/* val = copy_tag_value(reply->payload_utf8, "type");
if (val && (strncmp(val, "PING", 4) == 0))
type = PING;
free(val);
val = copy_tag_value(reply->payload_utf8, "sessionId");
if (val)
{
if (session_id)
free(session_id);
session_id = val;
}
val = copy_tag_value(reply->payload_utf8, "transportId");
if (val)
{
if (appid)
free(appid);
appid = val;
}
*/
extensions__core_api__cast_channel__cast_message__free_unpacked(reply, NULL);
return type;
}
static void
cast_session_free(struct cast_session *cs)
{
event_free(cs->ev);
gnutls_bye(cs->tls_session, GNUTLS_SHUT_RDWR);
close(cs->server_fd);
gnutls_deinit(cs->tls_session);
if (cs->address)
free(cs->address);
if (cs->devname)
free(cs->devname);
free(cs);
}
static void
cast_session_cleanup(struct cast_session *cs)
{
struct cast_session *s;
if (cs == sessions)
sessions = sessions->next;
else
{
for (s = sessions; s && (s->next != cs); s = s->next)
; /* EMPTY */
if (!s)
DPRINTF(E_WARN, L_CAST, "WARNING: struct cast_session not found in list; BUG!\n");
else
s->next = cs->next;
}
cast_session_free(cs);
}
static void
cast_session_failure(struct cast_session *cs)
{
/* Session failed, let our user know */
cs->status_cb(cs->dev, NULL, RAOP_FAILED);
cast_session_cleanup(cs);
}
static void
cast_listen_cb(int fd, short what, void *arg)
{
struct cast_session *cs;
enum cast_msg_type type;
uint8_t buffer[MAX_BUF + 1]; // Not sure about the +1, but is copied from gnutls examples
uint32_t be;
size_t len;
int ret;
cs = (struct cast_session *)arg;
DPRINTF(E_DBG, L_CAST, "New data from %s\n", cs->devname);
len = 0;
while ( (ret = gnutls_record_recv(cs->tls_session, buffer, MAX_BUF)) > 0)
{
DPRINTF(E_DBG, L_CAST, "Received %d bytes\n", ret);
if (ret == 4)
{
memcpy(&be, buffer, 4);
len = be32toh(be);
DPRINTF(E_DBG, L_CAST, "Incoming %d bytes\n", len);
}
else if (len > 0)
{
len = 0;
type = cast_msg_unpack(buffer, ret);
/* if (type == PING)
{
send_message(&session, PONG);
exec = 1;
n++;
}
*/
}
else
DPRINTF(E_WARN, L_CAST, "Unknown reponse from %s\n", cs->devname);
}
cast_session_failure(cs);
}
static struct cast_session *
cast_session_make(struct raop_device *rd, int family, raop_status_cb cb)
{
struct cast_session *cs;
const char *proto;
const char *err;
char *address;
unsigned short port;
int ret;
switch (family)
{
case AF_INET:
/* We always have the v4 services, so no need to check */
if (!rd->v4_address)
return NULL;
address = rd->v4_address;
port = rd->v4_port;
break;
case AF_INET6:
if (!rd->v6_address)
return NULL;
address = rd->v6_address;
port = rd->v6_port;
break;
default:
return NULL;
}
cs = calloc(1, sizeof(struct cast_session));
if (!cs)
{
DPRINTF(E_LOG, L_CAST, "Out of memory for TLS session\n");
return NULL;
}
cs->dev = rd;
cs->status_cb = cb;
/* Init TLS session, use default priorities and put the x509 credentials to the current session */
if ( ((ret = gnutls_init(&cs->tls_session, GNUTLS_CLIENT)) != GNUTLS_E_SUCCESS) ||
((ret = gnutls_priority_set_direct(cs->tls_session, "PERFORMANCE", &err)) != GNUTLS_E_SUCCESS) ||
((ret = gnutls_credentials_set(cs->tls_session, GNUTLS_CRD_CERTIFICATE, tls_credentials)) != GNUTLS_E_SUCCESS) )
{
DPRINTF(E_LOG, L_CAST, "Could not initialize GNUTLS session: %s\n", gnutls_strerror(ret));
goto out_free_session;
}
cs->server_fd = tcp_connect(address, port, family);
if (cs->server_fd < 0)
goto out_deinit_gnutls;
cs->ev = event_new(evbase_player, cs->server_fd, EV_READ, cast_listen_cb, cs);
if (!cs->ev)
{
DPRINTF(E_LOG, L_CAST, "Out of memory for listener event\n");
goto out_close_connection;
}
gnutls_transport_set_ptr(cs->tls_session, (gnutls_transport_ptr_t)cs->server_fd);
ret = gnutls_handshake(cs->tls_session);
if (ret != GNUTLS_E_SUCCESS)
{
DPRINTF(E_LOG, L_CAST, "Could not attach TLS to TCP connection: %s\n", gnutls_strerror(ret));
goto out_free_ev;
}
event_add(cs->ev, NULL);
cs->devname = strdup(rd->name);
cs->address = strdup(address);
cs->volume = rd->volume;
cs->next = sessions;
sessions = cs;
proto = gnutls_protocol_get_name(gnutls_protocol_get_version(cs->tls_session));
DPRINTF(E_INFO, L_CAST, "Connection to %s established using %s\n", cs->devname, proto);
return cs;
out_free_ev:
event_free(cs->ev);
out_close_connection:
tcp_close(cs->server_fd);
out_deinit_gnutls:
gnutls_deinit(cs->tls_session);
out_free_session:
free(cs);
return NULL;
}
int
cast_device_start(struct raop_device *rd, raop_status_cb cb)
{
DPRINTF(E_LOG, L_CAST, "Got start request for %s\n", rd->name);
struct cast_session *cs;
int ret;
cs = cast_session_make(rd, AF_INET6, cb);
if (cs)
{
return 0;
/* ret = raop_send_req_options(rs, raop_cb_startup_options);
if (ret == 0)
return 0;
else
{
DPRINTF(E_WARN, L_RAOP, "Could not send OPTIONS request on IPv6 (start)\n");
raop_session_cleanup(rs);
}
*/
}
cs = cast_session_make(rd, AF_INET, cb);
if (!cs)
return -1;
/* ret = raop_send_req_options(rs, raop_cb_startup_options);
if (ret < 0)
{
DPRINTF(E_WARN, L_RAOP, "Could not send OPTIONS request on IPv4 (start)\n");
raop_session_cleanup(rs);
return -1;
}
*/
return 0;
}
int
cast_init(void)
{
int ret;
// TODO Setting the cert file may not be required
if ( ((ret = gnutls_global_init()) != GNUTLS_E_SUCCESS) ||
((ret = gnutls_certificate_allocate_credentials(&tls_credentials)) != GNUTLS_E_SUCCESS) ||
((ret = gnutls_certificate_set_x509_trust_file(tls_credentials, CAFILE, GNUTLS_X509_FMT_PEM)) < 0) )
{
DPRINTF(E_LOG, L_CAST, "Could not initialize GNUTLS: %s\n", gnutls_strerror(ret));
return -1;
}
return 0;
}
void
cast_deinit(void)
{
struct cast_session *cs;
for (cs = sessions; sessions; cs = sessions)
{
sessions = cs->next;
cast_session_free(cs);
}
gnutls_certificate_free_credentials(tls_credentials);
gnutls_global_deinit();
}

58
src/cast.h Normal file
View File

@ -0,0 +1,58 @@
#ifndef __CAST_H__
#define __CAST_H__
#include "raop.h"
int
cast_device_start(struct raop_device *rd, raop_status_cb cb);
/*void
raop_metadata_purge(void);
void
raop_metadata_prune(uint64_t rtptime);
struct raop_metadata *
raop_metadata_prepare(int id);
void
raop_metadata_send(struct raop_metadata *rmd, uint64_t rtptime, uint64_t offset, int startup);
int
raop_device_probe(struct raop_device *rd, raop_status_cb cb);
int
raop_device_start(struct raop_device *rd, raop_status_cb cb, uint64_t rtptime);
void
raop_device_stop(struct raop_session *rs);
void
raop_playback_start(uint64_t next_pkt, struct timespec *ts);
void
raop_playback_stop(void);
int
raop_set_volume_one(struct raop_session *rs, int volume, raop_status_cb cb);
int
raop_flush(raop_status_cb cb, uint64_t rtptime);
void
raop_set_status_cb(struct raop_session *rs, raop_status_cb cb);
void
raop_v2_write(uint8_t *buf, uint64_t rtptime);
*/
int
cast_init(void);
void
cast_deinit(void);
#endif /* !__CAST_H__ */

672
src/cast_channel.pb-c.c Normal file
View File

@ -0,0 +1,672 @@
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
/* Do not generate deprecated warnings for self */
#ifndef PROTOBUF_C_NO_DEPRECATED
#define PROTOBUF_C_NO_DEPRECATED
#endif
#include "cast_channel.pb-c.h"
void extensions__core_api__cast_channel__cast_message__init
(Extensions__CoreApi__CastChannel__CastMessage *message)
{
static Extensions__CoreApi__CastChannel__CastMessage init_value = EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__INIT;
*message = init_value;
}
size_t extensions__core_api__cast_channel__cast_message__get_packed_size
(const Extensions__CoreApi__CastChannel__CastMessage *message)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__cast_message__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t extensions__core_api__cast_channel__cast_message__pack
(const Extensions__CoreApi__CastChannel__CastMessage *message,
uint8_t *out)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__cast_message__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t extensions__core_api__cast_channel__cast_message__pack_to_buffer
(const Extensions__CoreApi__CastChannel__CastMessage *message,
ProtobufCBuffer *buffer)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__cast_message__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Extensions__CoreApi__CastChannel__CastMessage *
extensions__core_api__cast_channel__cast_message__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Extensions__CoreApi__CastChannel__CastMessage *)
protobuf_c_message_unpack (&extensions__core_api__cast_channel__cast_message__descriptor,
allocator, len, data);
}
void extensions__core_api__cast_channel__cast_message__free_unpacked
(Extensions__CoreApi__CastChannel__CastMessage *message,
ProtobufCAllocator *allocator)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__cast_message__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void extensions__core_api__cast_channel__auth_challenge__init
(Extensions__CoreApi__CastChannel__AuthChallenge *message)
{
static Extensions__CoreApi__CastChannel__AuthChallenge init_value = EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_CHALLENGE__INIT;
*message = init_value;
}
size_t extensions__core_api__cast_channel__auth_challenge__get_packed_size
(const Extensions__CoreApi__CastChannel__AuthChallenge *message)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_challenge__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t extensions__core_api__cast_channel__auth_challenge__pack
(const Extensions__CoreApi__CastChannel__AuthChallenge *message,
uint8_t *out)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_challenge__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t extensions__core_api__cast_channel__auth_challenge__pack_to_buffer
(const Extensions__CoreApi__CastChannel__AuthChallenge *message,
ProtobufCBuffer *buffer)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_challenge__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Extensions__CoreApi__CastChannel__AuthChallenge *
extensions__core_api__cast_channel__auth_challenge__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Extensions__CoreApi__CastChannel__AuthChallenge *)
protobuf_c_message_unpack (&extensions__core_api__cast_channel__auth_challenge__descriptor,
allocator, len, data);
}
void extensions__core_api__cast_channel__auth_challenge__free_unpacked
(Extensions__CoreApi__CastChannel__AuthChallenge *message,
ProtobufCAllocator *allocator)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_challenge__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void extensions__core_api__cast_channel__auth_response__init
(Extensions__CoreApi__CastChannel__AuthResponse *message)
{
static Extensions__CoreApi__CastChannel__AuthResponse init_value = EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_RESPONSE__INIT;
*message = init_value;
}
size_t extensions__core_api__cast_channel__auth_response__get_packed_size
(const Extensions__CoreApi__CastChannel__AuthResponse *message)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_response__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t extensions__core_api__cast_channel__auth_response__pack
(const Extensions__CoreApi__CastChannel__AuthResponse *message,
uint8_t *out)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_response__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t extensions__core_api__cast_channel__auth_response__pack_to_buffer
(const Extensions__CoreApi__CastChannel__AuthResponse *message,
ProtobufCBuffer *buffer)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_response__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Extensions__CoreApi__CastChannel__AuthResponse *
extensions__core_api__cast_channel__auth_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Extensions__CoreApi__CastChannel__AuthResponse *)
protobuf_c_message_unpack (&extensions__core_api__cast_channel__auth_response__descriptor,
allocator, len, data);
}
void extensions__core_api__cast_channel__auth_response__free_unpacked
(Extensions__CoreApi__CastChannel__AuthResponse *message,
ProtobufCAllocator *allocator)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_response__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void extensions__core_api__cast_channel__auth_error__init
(Extensions__CoreApi__CastChannel__AuthError *message)
{
static Extensions__CoreApi__CastChannel__AuthError init_value = EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__INIT;
*message = init_value;
}
size_t extensions__core_api__cast_channel__auth_error__get_packed_size
(const Extensions__CoreApi__CastChannel__AuthError *message)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_error__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t extensions__core_api__cast_channel__auth_error__pack
(const Extensions__CoreApi__CastChannel__AuthError *message,
uint8_t *out)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_error__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t extensions__core_api__cast_channel__auth_error__pack_to_buffer
(const Extensions__CoreApi__CastChannel__AuthError *message,
ProtobufCBuffer *buffer)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_error__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Extensions__CoreApi__CastChannel__AuthError *
extensions__core_api__cast_channel__auth_error__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Extensions__CoreApi__CastChannel__AuthError *)
protobuf_c_message_unpack (&extensions__core_api__cast_channel__auth_error__descriptor,
allocator, len, data);
}
void extensions__core_api__cast_channel__auth_error__free_unpacked
(Extensions__CoreApi__CastChannel__AuthError *message,
ProtobufCAllocator *allocator)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__auth_error__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void extensions__core_api__cast_channel__device_auth_message__init
(Extensions__CoreApi__CastChannel__DeviceAuthMessage *message)
{
static Extensions__CoreApi__CastChannel__DeviceAuthMessage init_value = EXTENSIONS__CORE_API__CAST_CHANNEL__DEVICE_AUTH_MESSAGE__INIT;
*message = init_value;
}
size_t extensions__core_api__cast_channel__device_auth_message__get_packed_size
(const Extensions__CoreApi__CastChannel__DeviceAuthMessage *message)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__device_auth_message__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t extensions__core_api__cast_channel__device_auth_message__pack
(const Extensions__CoreApi__CastChannel__DeviceAuthMessage *message,
uint8_t *out)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__device_auth_message__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t extensions__core_api__cast_channel__device_auth_message__pack_to_buffer
(const Extensions__CoreApi__CastChannel__DeviceAuthMessage *message,
ProtobufCBuffer *buffer)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__device_auth_message__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Extensions__CoreApi__CastChannel__DeviceAuthMessage *
extensions__core_api__cast_channel__device_auth_message__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Extensions__CoreApi__CastChannel__DeviceAuthMessage *)
protobuf_c_message_unpack (&extensions__core_api__cast_channel__device_auth_message__descriptor,
allocator, len, data);
}
void extensions__core_api__cast_channel__device_auth_message__free_unpacked
(Extensions__CoreApi__CastChannel__DeviceAuthMessage *message,
ProtobufCAllocator *allocator)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &extensions__core_api__cast_channel__device_auth_message__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
const ProtobufCEnumValue extensions__core_api__cast_channel__cast_message__protocol_version__enum_values_by_number[1] =
{
{ "CASTV2_1_0", "EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__PROTOCOL_VERSION__CASTV2_1_0", 0 },
};
static const ProtobufCIntRange extensions__core_api__cast_channel__cast_message__protocol_version__value_ranges[] = {
{0, 0},{0, 1}
};
const ProtobufCEnumValueIndex extensions__core_api__cast_channel__cast_message__protocol_version__enum_values_by_name[1] =
{
{ "CASTV2_1_0", 0 },
};
const ProtobufCEnumDescriptor extensions__core_api__cast_channel__cast_message__protocol_version__descriptor =
{
PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.CastMessage.ProtocolVersion",
"ProtocolVersion",
"Extensions__CoreApi__CastChannel__CastMessage__ProtocolVersion",
"extensions.core_api.cast_channel",
1,
extensions__core_api__cast_channel__cast_message__protocol_version__enum_values_by_number,
1,
extensions__core_api__cast_channel__cast_message__protocol_version__enum_values_by_name,
1,
extensions__core_api__cast_channel__cast_message__protocol_version__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};
const ProtobufCEnumValue extensions__core_api__cast_channel__cast_message__payload_type__enum_values_by_number[2] =
{
{ "STRING", "EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__PAYLOAD_TYPE__STRING", 0 },
{ "BINARY", "EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__PAYLOAD_TYPE__BINARY", 1 },
};
static const ProtobufCIntRange extensions__core_api__cast_channel__cast_message__payload_type__value_ranges[] = {
{0, 0},{0, 2}
};
const ProtobufCEnumValueIndex extensions__core_api__cast_channel__cast_message__payload_type__enum_values_by_name[2] =
{
{ "BINARY", 1 },
{ "STRING", 0 },
};
const ProtobufCEnumDescriptor extensions__core_api__cast_channel__cast_message__payload_type__descriptor =
{
PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.CastMessage.PayloadType",
"PayloadType",
"Extensions__CoreApi__CastChannel__CastMessage__PayloadType",
"extensions.core_api.cast_channel",
2,
extensions__core_api__cast_channel__cast_message__payload_type__enum_values_by_number,
2,
extensions__core_api__cast_channel__cast_message__payload_type__enum_values_by_name,
1,
extensions__core_api__cast_channel__cast_message__payload_type__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};
static const ProtobufCFieldDescriptor extensions__core_api__cast_channel__cast_message__field_descriptors[7] =
{
{
"protocol_version",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, protocol_version),
&extensions__core_api__cast_channel__cast_message__protocol_version__descriptor,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"source_id",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, source_id),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"destination_id",
3,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, destination_id),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"namespace",
4,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, namespace_),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"payload_type",
5,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, payload_type),
&extensions__core_api__cast_channel__cast_message__payload_type__descriptor,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"payload_utf8",
6,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, payload_utf8),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"payload_binary",
7,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BYTES,
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, has_payload_binary),
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__CastMessage, payload_binary),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned extensions__core_api__cast_channel__cast_message__field_indices_by_name[] = {
2, /* field[2] = destination_id */
3, /* field[3] = namespace */
6, /* field[6] = payload_binary */
4, /* field[4] = payload_type */
5, /* field[5] = payload_utf8 */
0, /* field[0] = protocol_version */
1, /* field[1] = source_id */
};
static const ProtobufCIntRange extensions__core_api__cast_channel__cast_message__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 7 }
};
const ProtobufCMessageDescriptor extensions__core_api__cast_channel__cast_message__descriptor =
{
PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.CastMessage",
"CastMessage",
"Extensions__CoreApi__CastChannel__CastMessage",
"extensions.core_api.cast_channel",
sizeof(Extensions__CoreApi__CastChannel__CastMessage),
7,
extensions__core_api__cast_channel__cast_message__field_descriptors,
extensions__core_api__cast_channel__cast_message__field_indices_by_name,
1, extensions__core_api__cast_channel__cast_message__number_ranges,
(ProtobufCMessageInit) extensions__core_api__cast_channel__cast_message__init,
NULL,NULL,NULL /* reserved[123] */
};
static const Extensions__CoreApi__CastChannel__SignatureAlgorithm extensions__core_api__cast_channel__auth_challenge__signature_algorithm__default_value = EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PKCS1V15;
static const ProtobufCFieldDescriptor extensions__core_api__cast_channel__auth_challenge__field_descriptors[1] =
{
{
"signature_algorithm",
1,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_ENUM,
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthChallenge, has_signature_algorithm),
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthChallenge, signature_algorithm),
&extensions__core_api__cast_channel__signature_algorithm__descriptor,
&extensions__core_api__cast_channel__auth_challenge__signature_algorithm__default_value,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned extensions__core_api__cast_channel__auth_challenge__field_indices_by_name[] = {
0, /* field[0] = signature_algorithm */
};
static const ProtobufCIntRange extensions__core_api__cast_channel__auth_challenge__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor extensions__core_api__cast_channel__auth_challenge__descriptor =
{
PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.AuthChallenge",
"AuthChallenge",
"Extensions__CoreApi__CastChannel__AuthChallenge",
"extensions.core_api.cast_channel",
sizeof(Extensions__CoreApi__CastChannel__AuthChallenge),
1,
extensions__core_api__cast_channel__auth_challenge__field_descriptors,
extensions__core_api__cast_channel__auth_challenge__field_indices_by_name,
1, extensions__core_api__cast_channel__auth_challenge__number_ranges,
(ProtobufCMessageInit) extensions__core_api__cast_channel__auth_challenge__init,
NULL,NULL,NULL /* reserved[123] */
};
static const Extensions__CoreApi__CastChannel__SignatureAlgorithm extensions__core_api__cast_channel__auth_response__signature_algorithm__default_value = EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PKCS1V15;
static const ProtobufCFieldDescriptor extensions__core_api__cast_channel__auth_response__field_descriptors[4] =
{
{
"signature",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthResponse, signature),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"client_auth_certificate",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthResponse, client_auth_certificate),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"intermediate_certificate",
3,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_BYTES,
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthResponse, n_intermediate_certificate),
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthResponse, intermediate_certificate),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"signature_algorithm",
4,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_ENUM,
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthResponse, has_signature_algorithm),
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthResponse, signature_algorithm),
&extensions__core_api__cast_channel__signature_algorithm__descriptor,
&extensions__core_api__cast_channel__auth_response__signature_algorithm__default_value,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned extensions__core_api__cast_channel__auth_response__field_indices_by_name[] = {
1, /* field[1] = client_auth_certificate */
2, /* field[2] = intermediate_certificate */
0, /* field[0] = signature */
3, /* field[3] = signature_algorithm */
};
static const ProtobufCIntRange extensions__core_api__cast_channel__auth_response__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 4 }
};
const ProtobufCMessageDescriptor extensions__core_api__cast_channel__auth_response__descriptor =
{
PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.AuthResponse",
"AuthResponse",
"Extensions__CoreApi__CastChannel__AuthResponse",
"extensions.core_api.cast_channel",
sizeof(Extensions__CoreApi__CastChannel__AuthResponse),
4,
extensions__core_api__cast_channel__auth_response__field_descriptors,
extensions__core_api__cast_channel__auth_response__field_indices_by_name,
1, extensions__core_api__cast_channel__auth_response__number_ranges,
(ProtobufCMessageInit) extensions__core_api__cast_channel__auth_response__init,
NULL,NULL,NULL /* reserved[123] */
};
const ProtobufCEnumValue extensions__core_api__cast_channel__auth_error__error_type__enum_values_by_number[3] =
{
{ "INTERNAL_ERROR", "EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__ERROR_TYPE__INTERNAL_ERROR", 0 },
{ "NO_TLS", "EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__ERROR_TYPE__NO_TLS", 1 },
{ "SIGNATURE_ALGORITHM_UNAVAILABLE", "EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__ERROR_TYPE__SIGNATURE_ALGORITHM_UNAVAILABLE", 2 },
};
static const ProtobufCIntRange extensions__core_api__cast_channel__auth_error__error_type__value_ranges[] = {
{0, 0},{0, 3}
};
const ProtobufCEnumValueIndex extensions__core_api__cast_channel__auth_error__error_type__enum_values_by_name[3] =
{
{ "INTERNAL_ERROR", 0 },
{ "NO_TLS", 1 },
{ "SIGNATURE_ALGORITHM_UNAVAILABLE", 2 },
};
const ProtobufCEnumDescriptor extensions__core_api__cast_channel__auth_error__error_type__descriptor =
{
PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.AuthError.ErrorType",
"ErrorType",
"Extensions__CoreApi__CastChannel__AuthError__ErrorType",
"extensions.core_api.cast_channel",
3,
extensions__core_api__cast_channel__auth_error__error_type__enum_values_by_number,
3,
extensions__core_api__cast_channel__auth_error__error_type__enum_values_by_name,
1,
extensions__core_api__cast_channel__auth_error__error_type__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};
static const ProtobufCFieldDescriptor extensions__core_api__cast_channel__auth_error__field_descriptors[1] =
{
{
"error_type",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__AuthError, error_type),
&extensions__core_api__cast_channel__auth_error__error_type__descriptor,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned extensions__core_api__cast_channel__auth_error__field_indices_by_name[] = {
0, /* field[0] = error_type */
};
static const ProtobufCIntRange extensions__core_api__cast_channel__auth_error__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor extensions__core_api__cast_channel__auth_error__descriptor =
{
PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.AuthError",
"AuthError",
"Extensions__CoreApi__CastChannel__AuthError",
"extensions.core_api.cast_channel",
sizeof(Extensions__CoreApi__CastChannel__AuthError),
1,
extensions__core_api__cast_channel__auth_error__field_descriptors,
extensions__core_api__cast_channel__auth_error__field_indices_by_name,
1, extensions__core_api__cast_channel__auth_error__number_ranges,
(ProtobufCMessageInit) extensions__core_api__cast_channel__auth_error__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor extensions__core_api__cast_channel__device_auth_message__field_descriptors[3] =
{
{
"challenge",
1,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__DeviceAuthMessage, challenge),
&extensions__core_api__cast_channel__auth_challenge__descriptor,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"response",
2,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__DeviceAuthMessage, response),
&extensions__core_api__cast_channel__auth_response__descriptor,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"error",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Extensions__CoreApi__CastChannel__DeviceAuthMessage, error),
&extensions__core_api__cast_channel__auth_error__descriptor,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned extensions__core_api__cast_channel__device_auth_message__field_indices_by_name[] = {
0, /* field[0] = challenge */
2, /* field[2] = error */
1, /* field[1] = response */
};
static const ProtobufCIntRange extensions__core_api__cast_channel__device_auth_message__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
};
const ProtobufCMessageDescriptor extensions__core_api__cast_channel__device_auth_message__descriptor =
{
PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.DeviceAuthMessage",
"DeviceAuthMessage",
"Extensions__CoreApi__CastChannel__DeviceAuthMessage",
"extensions.core_api.cast_channel",
sizeof(Extensions__CoreApi__CastChannel__DeviceAuthMessage),
3,
extensions__core_api__cast_channel__device_auth_message__field_descriptors,
extensions__core_api__cast_channel__device_auth_message__field_indices_by_name,
1, extensions__core_api__cast_channel__device_auth_message__number_ranges,
(ProtobufCMessageInit) extensions__core_api__cast_channel__device_auth_message__init,
NULL,NULL,NULL /* reserved[123] */
};
const ProtobufCEnumValue extensions__core_api__cast_channel__signature_algorithm__enum_values_by_number[3] =
{
{ "UNSPECIFIED", "EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__UNSPECIFIED", 0 },
{ "RSASSA_PKCS1v15", "EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PKCS1V15", 1 },
{ "RSASSA_PSS", "EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PSS", 2 },
};
static const ProtobufCIntRange extensions__core_api__cast_channel__signature_algorithm__value_ranges[] = {
{0, 0},{0, 3}
};
const ProtobufCEnumValueIndex extensions__core_api__cast_channel__signature_algorithm__enum_values_by_name[3] =
{
{ "RSASSA_PKCS1v15", 1 },
{ "RSASSA_PSS", 2 },
{ "UNSPECIFIED", 0 },
};
const ProtobufCEnumDescriptor extensions__core_api__cast_channel__signature_algorithm__descriptor =
{
PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC,
"extensions.core_api.cast_channel.SignatureAlgorithm",
"SignatureAlgorithm",
"Extensions__CoreApi__CastChannel__SignatureAlgorithm",
"extensions.core_api.cast_channel",
3,
extensions__core_api__cast_channel__signature_algorithm__enum_values_by_number,
3,
extensions__core_api__cast_channel__signature_algorithm__enum_values_by_name,
1,
extensions__core_api__cast_channel__signature_algorithm__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};

236
src/cast_channel.pb-c.h Normal file
View File

@ -0,0 +1,236 @@
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
#ifndef PROTOBUF_C_cast_5fchannel_2eproto__INCLUDED
#define PROTOBUF_C_cast_5fchannel_2eproto__INCLUDED
#include <google/protobuf-c/protobuf-c.h>
PROTOBUF_C_BEGIN_DECLS
typedef struct _Extensions__CoreApi__CastChannel__CastMessage Extensions__CoreApi__CastChannel__CastMessage;
typedef struct _Extensions__CoreApi__CastChannel__AuthChallenge Extensions__CoreApi__CastChannel__AuthChallenge;
typedef struct _Extensions__CoreApi__CastChannel__AuthResponse Extensions__CoreApi__CastChannel__AuthResponse;
typedef struct _Extensions__CoreApi__CastChannel__AuthError Extensions__CoreApi__CastChannel__AuthError;
typedef struct _Extensions__CoreApi__CastChannel__DeviceAuthMessage Extensions__CoreApi__CastChannel__DeviceAuthMessage;
/* --- enums --- */
typedef enum _Extensions__CoreApi__CastChannel__CastMessage__ProtocolVersion {
EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__PROTOCOL_VERSION__CASTV2_1_0 = 0
} Extensions__CoreApi__CastChannel__CastMessage__ProtocolVersion;
typedef enum _Extensions__CoreApi__CastChannel__CastMessage__PayloadType {
EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__PAYLOAD_TYPE__STRING = 0,
EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__PAYLOAD_TYPE__BINARY = 1
} Extensions__CoreApi__CastChannel__CastMessage__PayloadType;
typedef enum _Extensions__CoreApi__CastChannel__AuthError__ErrorType {
EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__ERROR_TYPE__INTERNAL_ERROR = 0,
EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__ERROR_TYPE__NO_TLS = 1,
EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__ERROR_TYPE__SIGNATURE_ALGORITHM_UNAVAILABLE = 2
} Extensions__CoreApi__CastChannel__AuthError__ErrorType;
typedef enum _Extensions__CoreApi__CastChannel__SignatureAlgorithm {
EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__UNSPECIFIED = 0,
EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PKCS1V15 = 1,
EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PSS = 2
} Extensions__CoreApi__CastChannel__SignatureAlgorithm;
/* --- messages --- */
struct _Extensions__CoreApi__CastChannel__CastMessage
{
ProtobufCMessage base;
Extensions__CoreApi__CastChannel__CastMessage__ProtocolVersion protocol_version;
char *source_id;
char *destination_id;
char *namespace_;
Extensions__CoreApi__CastChannel__CastMessage__PayloadType payload_type;
char *payload_utf8;
protobuf_c_boolean has_payload_binary;
ProtobufCBinaryData payload_binary;
};
#define EXTENSIONS__CORE_API__CAST_CHANNEL__CAST_MESSAGE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&extensions__core_api__cast_channel__cast_message__descriptor) \
, 0, NULL, NULL, NULL, 0, NULL, 0,{0,NULL} }
struct _Extensions__CoreApi__CastChannel__AuthChallenge
{
ProtobufCMessage base;
protobuf_c_boolean has_signature_algorithm;
Extensions__CoreApi__CastChannel__SignatureAlgorithm signature_algorithm;
};
#define EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_CHALLENGE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&extensions__core_api__cast_channel__auth_challenge__descriptor) \
, 0,EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PKCS1V15 }
struct _Extensions__CoreApi__CastChannel__AuthResponse
{
ProtobufCMessage base;
ProtobufCBinaryData signature;
ProtobufCBinaryData client_auth_certificate;
size_t n_intermediate_certificate;
ProtobufCBinaryData *intermediate_certificate;
protobuf_c_boolean has_signature_algorithm;
Extensions__CoreApi__CastChannel__SignatureAlgorithm signature_algorithm;
};
#define EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&extensions__core_api__cast_channel__auth_response__descriptor) \
, {0,NULL}, {0,NULL}, 0,NULL, 0,EXTENSIONS__CORE_API__CAST_CHANNEL__SIGNATURE_ALGORITHM__RSASSA_PKCS1V15 }
struct _Extensions__CoreApi__CastChannel__AuthError
{
ProtobufCMessage base;
Extensions__CoreApi__CastChannel__AuthError__ErrorType error_type;
};
#define EXTENSIONS__CORE_API__CAST_CHANNEL__AUTH_ERROR__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&extensions__core_api__cast_channel__auth_error__descriptor) \
, 0 }
struct _Extensions__CoreApi__CastChannel__DeviceAuthMessage
{
ProtobufCMessage base;
Extensions__CoreApi__CastChannel__AuthChallenge *challenge;
Extensions__CoreApi__CastChannel__AuthResponse *response;
Extensions__CoreApi__CastChannel__AuthError *error;
};
#define EXTENSIONS__CORE_API__CAST_CHANNEL__DEVICE_AUTH_MESSAGE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&extensions__core_api__cast_channel__device_auth_message__descriptor) \
, NULL, NULL, NULL }
/* Extensions__CoreApi__CastChannel__CastMessage methods */
void extensions__core_api__cast_channel__cast_message__init
(Extensions__CoreApi__CastChannel__CastMessage *message);
size_t extensions__core_api__cast_channel__cast_message__get_packed_size
(const Extensions__CoreApi__CastChannel__CastMessage *message);
size_t extensions__core_api__cast_channel__cast_message__pack
(const Extensions__CoreApi__CastChannel__CastMessage *message,
uint8_t *out);
size_t extensions__core_api__cast_channel__cast_message__pack_to_buffer
(const Extensions__CoreApi__CastChannel__CastMessage *message,
ProtobufCBuffer *buffer);
Extensions__CoreApi__CastChannel__CastMessage *
extensions__core_api__cast_channel__cast_message__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void extensions__core_api__cast_channel__cast_message__free_unpacked
(Extensions__CoreApi__CastChannel__CastMessage *message,
ProtobufCAllocator *allocator);
/* Extensions__CoreApi__CastChannel__AuthChallenge methods */
void extensions__core_api__cast_channel__auth_challenge__init
(Extensions__CoreApi__CastChannel__AuthChallenge *message);
size_t extensions__core_api__cast_channel__auth_challenge__get_packed_size
(const Extensions__CoreApi__CastChannel__AuthChallenge *message);
size_t extensions__core_api__cast_channel__auth_challenge__pack
(const Extensions__CoreApi__CastChannel__AuthChallenge *message,
uint8_t *out);
size_t extensions__core_api__cast_channel__auth_challenge__pack_to_buffer
(const Extensions__CoreApi__CastChannel__AuthChallenge *message,
ProtobufCBuffer *buffer);
Extensions__CoreApi__CastChannel__AuthChallenge *
extensions__core_api__cast_channel__auth_challenge__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void extensions__core_api__cast_channel__auth_challenge__free_unpacked
(Extensions__CoreApi__CastChannel__AuthChallenge *message,
ProtobufCAllocator *allocator);
/* Extensions__CoreApi__CastChannel__AuthResponse methods */
void extensions__core_api__cast_channel__auth_response__init
(Extensions__CoreApi__CastChannel__AuthResponse *message);
size_t extensions__core_api__cast_channel__auth_response__get_packed_size
(const Extensions__CoreApi__CastChannel__AuthResponse *message);
size_t extensions__core_api__cast_channel__auth_response__pack
(const Extensions__CoreApi__CastChannel__AuthResponse *message,
uint8_t *out);
size_t extensions__core_api__cast_channel__auth_response__pack_to_buffer
(const Extensions__CoreApi__CastChannel__AuthResponse *message,
ProtobufCBuffer *buffer);
Extensions__CoreApi__CastChannel__AuthResponse *
extensions__core_api__cast_channel__auth_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void extensions__core_api__cast_channel__auth_response__free_unpacked
(Extensions__CoreApi__CastChannel__AuthResponse *message,
ProtobufCAllocator *allocator);
/* Extensions__CoreApi__CastChannel__AuthError methods */
void extensions__core_api__cast_channel__auth_error__init
(Extensions__CoreApi__CastChannel__AuthError *message);
size_t extensions__core_api__cast_channel__auth_error__get_packed_size
(const Extensions__CoreApi__CastChannel__AuthError *message);
size_t extensions__core_api__cast_channel__auth_error__pack
(const Extensions__CoreApi__CastChannel__AuthError *message,
uint8_t *out);
size_t extensions__core_api__cast_channel__auth_error__pack_to_buffer
(const Extensions__CoreApi__CastChannel__AuthError *message,
ProtobufCBuffer *buffer);
Extensions__CoreApi__CastChannel__AuthError *
extensions__core_api__cast_channel__auth_error__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void extensions__core_api__cast_channel__auth_error__free_unpacked
(Extensions__CoreApi__CastChannel__AuthError *message,
ProtobufCAllocator *allocator);
/* Extensions__CoreApi__CastChannel__DeviceAuthMessage methods */
void extensions__core_api__cast_channel__device_auth_message__init
(Extensions__CoreApi__CastChannel__DeviceAuthMessage *message);
size_t extensions__core_api__cast_channel__device_auth_message__get_packed_size
(const Extensions__CoreApi__CastChannel__DeviceAuthMessage *message);
size_t extensions__core_api__cast_channel__device_auth_message__pack
(const Extensions__CoreApi__CastChannel__DeviceAuthMessage *message,
uint8_t *out);
size_t extensions__core_api__cast_channel__device_auth_message__pack_to_buffer
(const Extensions__CoreApi__CastChannel__DeviceAuthMessage *message,
ProtobufCBuffer *buffer);
Extensions__CoreApi__CastChannel__DeviceAuthMessage *
extensions__core_api__cast_channel__device_auth_message__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void extensions__core_api__cast_channel__device_auth_message__free_unpacked
(Extensions__CoreApi__CastChannel__DeviceAuthMessage *message,
ProtobufCAllocator *allocator);
/* --- per-message closures --- */
typedef void (*Extensions__CoreApi__CastChannel__CastMessage_Closure)
(const Extensions__CoreApi__CastChannel__CastMessage *message,
void *closure_data);
typedef void (*Extensions__CoreApi__CastChannel__AuthChallenge_Closure)
(const Extensions__CoreApi__CastChannel__AuthChallenge *message,
void *closure_data);
typedef void (*Extensions__CoreApi__CastChannel__AuthResponse_Closure)
(const Extensions__CoreApi__CastChannel__AuthResponse *message,
void *closure_data);
typedef void (*Extensions__CoreApi__CastChannel__AuthError_Closure)
(const Extensions__CoreApi__CastChannel__AuthError *message,
void *closure_data);
typedef void (*Extensions__CoreApi__CastChannel__DeviceAuthMessage_Closure)
(const Extensions__CoreApi__CastChannel__DeviceAuthMessage *message,
void *closure_data);
/* --- services --- */
/* --- descriptors --- */
extern const ProtobufCEnumDescriptor extensions__core_api__cast_channel__signature_algorithm__descriptor;
extern const ProtobufCMessageDescriptor extensions__core_api__cast_channel__cast_message__descriptor;
extern const ProtobufCEnumDescriptor extensions__core_api__cast_channel__cast_message__protocol_version__descriptor;
extern const ProtobufCEnumDescriptor extensions__core_api__cast_channel__cast_message__payload_type__descriptor;
extern const ProtobufCMessageDescriptor extensions__core_api__cast_channel__auth_challenge__descriptor;
extern const ProtobufCMessageDescriptor extensions__core_api__cast_channel__auth_response__descriptor;
extern const ProtobufCMessageDescriptor extensions__core_api__cast_channel__auth_error__descriptor;
extern const ProtobufCEnumDescriptor extensions__core_api__cast_channel__auth_error__error_type__descriptor;
extern const ProtobufCMessageDescriptor extensions__core_api__cast_channel__device_auth_message__descriptor;
PROTOBUF_C_END_DECLS
#endif /* PROTOBUF_cast_5fchannel_2eproto__INCLUDED */

View File

@ -43,7 +43,7 @@ static int threshold;
static int console;
static char *logfilename;
static FILE *logfile;
static char *labels[] = { "config", "daap", "db", "httpd", "http", "main", "mdns", "misc", "rsp", "scan", "xcode", "event", "remote", "dacp", "ffmpeg", "artwork", "player", "raop", "laudio", "dmap", "dbperf", "spotify", "lastfm", "cache", "mpd", "stream" };
static char *labels[] = { "config", "daap", "db", "httpd", "http", "main", "mdns", "misc", "rsp", "scan", "xcode", "event", "remote", "dacp", "ffmpeg", "artwork", "player", "raop", "laudio", "dmap", "dbperf", "spotify", "lastfm", "cache", "mpd", "stream", "cast" };
static char *severities[] = { "FATAL", "LOG", "WARN", "INFO", "DEBUG", "SPAM" };

View File

@ -32,8 +32,9 @@
#define L_CACHE 23
#define L_MPD 24
#define L_STREAMING 25
#define L_CAST 26
#define N_LOGDOMAINS 26
#define N_LOGDOMAINS 27
/* Severities */
#define E_FATAL 0

View File

@ -560,9 +560,9 @@ trimwhitespace(const char *str)
}
uint32_t
djb_hash(void *data, size_t len)
djb_hash(const void *data, size_t len)
{
unsigned char *bytes = data;
const unsigned char *bytes = data;
uint32_t hash = 5381;
while (len--)

View File

@ -71,7 +71,7 @@ char *
trimwhitespace(const char *str);
uint32_t
djb_hash(void *data, size_t len);
djb_hash(const void *data, size_t len);
char *
b64_decode(const char *b64);

View File

@ -48,23 +48,29 @@
#include "conffile.h"
#include "misc.h"
#include "player.h"
#include "raop.h"
#include "laudio.h"
#include "worker.h"
#include "listener.h"
#ifdef LASTFM
# include "lastfm.h"
/* Audio outputs */
#include "raop.h"
#include "laudio.h"
#ifdef CHROMECAST
# include "cast.h"
#endif
/* These handle getting the media data */
/* Audio inputs */
#include "transcode.h"
#include "pipe.h"
#include "http.h"
#ifdef HAVE_SPOTIFY_H
# include "spotify.h"
#endif
/* Metadata input/output */
#include "http.h"
#ifdef LASTFM
# include "lastfm.h"
#endif
#ifndef MIN
# define MIN(a, b) ((a < b) ? a : b)
#endif
@ -236,6 +242,7 @@ static const char *raop_devtype[] =
"AirPort Express 2 - 802.11n",
"AirPort Express 3 - 802.11n",
"AppleTV",
"Chromecast",
"Other",
};
@ -4575,9 +4582,9 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
}
at_name++;
DPRINTF(E_DBG, L_PLAYER, "Event for AirPlay device %" PRIx64 "/%s (%d)\n", id, at_name, port);
DPRINTF(E_DBG, L_PLAYER, "Event for AirPlay device %s (port %d, id %" PRIx64 ")\n", at_name, port, id);
rd = (struct raop_device *)malloc(sizeof(struct raop_device));
rd = calloc(1, sizeof(struct raop_device));
if (!rd)
{
DPRINTF(E_LOG, L_PLAYER, "Out of memory for new AirPlay device\n");
@ -4585,8 +4592,6 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
return;
}
memset(rd, 0, sizeof(struct raop_device));
rd->id = id;
rd->name = strdup(at_name);
@ -4695,7 +4700,7 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
else
rd->wants_metadata = 0;
DPRINTF(E_INFO, L_PLAYER, "AirPlay device %s: password: %u, encrypt: %u, metadata: %u, type %s\n",
DPRINTF(E_INFO, L_PLAYER, "Adding AirPlay device %s: password: %u, encrypt: %u, metadata: %u, type %s\n",
name, rd->has_password, rd->encrypt, rd->wants_metadata, raop_devtype[rd->devtype]);
rd->advertised = 1;
@ -4721,6 +4726,81 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
device_free(rd);
}
static void
cast_device_cb(const char *name, const char *type, const char *domain, const char *hostname, int family, const char *address, int port, struct keyval *txt)
{
struct raop_device *d;
const char *p;
uint32_t id;
p = keyval_get(txt, "id");
if (p)
id = djb_hash(p, strlen(p));
else
id = 0;
if (!id)
{
DPRINTF(E_LOG, L_PLAYER, "Could not extract ChromeCast device ID (%s)\n", name);
return;
}
DPRINTF(E_DBG, L_PLAYER, "Event for Chromecast device %s (port %d, id %" PRIu32 ")\n", name, port, id);
d = calloc(1, sizeof(struct raop_device));
if (!d)
{
DPRINTF(E_LOG, L_PLAYER, "Out of memory for new Chromecast device\n");
return;
}
d->id = id;
d->name = strdup(name);
if (port < 0)
{
/* Device stopped advertising */
switch (family)
{
case AF_INET:
d->v4_port = 1;
break;
case AF_INET6:
d->v6_port = 1;
break;
}
player_device_remove(d);
return;
}
/* Device type */
d->devtype = RAOP_DEV_CHROMECAST;
DPRINTF(E_INFO, L_PLAYER, "Adding Chromecast device %s\n", name);
d->advertised = 1;
switch (family)
{
case AF_INET:
d->v4_address = strdup(address);
d->v4_port = port;
break;
case AF_INET6:
d->v6_address = strdup(address);
d->v6_port = port;
break;
}
player_device_add(d);
}
/* Thread: player */
static void *
player(void *arg)
@ -4944,6 +5024,16 @@ player_init(void)
goto mdns_browse_fail;
}
#ifdef CHROMECAST
ret = mdns_browse("_googlecast._tcp", mdns_flags, cast_device_cb);
if (ret < 0)
{
DPRINTF(E_FATAL, L_PLAYER, "Could not add mDNS browser for Chromecast devices\n");
goto mdns_browse_fail;
}
#endif
ret = pthread_create(&tid_player, NULL, player, NULL);
if (ret < 0)
{

View File

@ -18,6 +18,7 @@ enum raop_devtype {
RAOP_DEV_APEX2_80211N,
RAOP_DEV_APEX3_80211N,
RAOP_DEV_APPLETV,
RAOP_DEV_CHROMECAST,
RAOP_DEV_OTHER,
};