remove old files

This commit is contained in:
Wim Taymans 2016-07-28 21:30:15 +02:00
parent 4cb90f3b86
commit 7cfd1eb8ee
10 changed files with 7 additions and 1602 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,334 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PINOS_BUFFER_H__
#define __PINOS_BUFFER_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
typedef struct _PinosBuffer PinosBuffer;
#if 0
typedef struct _PinosBufferIter PinosBufferIter;
typedef struct _PinosBufferBuilder PinosBufferBuilder;
#define PINOS_BUFFER_VERSION 0
/**
* PinosBufferFlags:
* @PINOS_BUFFER_FLAG_NONE: no flags
* @PINOS_BUFFER_FLAG_CONTROL: the buffer contains control info such
* as new format or properties.
*
* The possible buffer flags.
*/
typedef enum {
PINOS_BUFFER_FLAG_NONE = 0,
PINOS_BUFFER_FLAG_CONTROL = (1 << 0),
} PinosBufferFlags;
struct _PinosBuffer {
PinosBuffer *next;
/*< private >*/
gsize x[16];
};
void pinos_buffer_init_data (PinosBuffer *buffer,
gpointer data,
gsize size,
gint *fds,
gint n_fds);
PinosBuffer * pinos_buffer_ref (PinosBuffer *buffer);
gboolean pinos_buffer_unref (PinosBuffer *buffer);
guint32 pinos_buffer_get_version (PinosBuffer *buffer);
PinosBufferFlags pinos_buffer_get_flags (PinosBuffer *buffer);
int pinos_buffer_get_fd (PinosBuffer *buffer,
gint index);
gpointer pinos_buffer_steal_data (PinosBuffer *buffer,
gsize *size);
gint * pinos_buffer_steal_fds (PinosBuffer *buffer,
gint *n_fds);
/**
* PinosPacketType:
* @PINOS_PACKET_TYPE_INVALID: invalid packet type, ignore
* @PINOS_PACKET_TYPE_CONTINUATION: continuation packet, used internally to send
* commands using a shared memory region.
* @PINOS_PACKET_TYPE_REGISTER_MEM: register memory region
* @PINOS_PACKET_TYPE_RELEASE_MEM: release memory region
* @PINOS_PACKET_TYPE_START: start transfer
* @PINOS_PACKET_TYPE_STOP: stop transfer
*
* @PINOS_PACKET_TYPE_HEADER: common packet header
* @PINOS_PACKET_TYPE_PROCESS_MEM: packet contains mem-payload. An mem-payload contains
* the media data as the index of a shared memory region
* @PINOS_PACKET_TYPE_REUSE_MEM: when a memory region has been consumed and is ready to
* be reused.
* @PINOS_PACKET_TYPE_FORMAT_CHANGE: a format change.
* @PINOS_PACKET_TYPE_PROPERTY_CHANGE: one or more property changes.
* @PINOS_PACKET_TYPE_REFRESH_REQUEST: ask for a new keyframe
*
* The possible packet types.
*/
typedef enum {
PINOS_PACKET_TYPE_INVALID = 0,
PINOS_PACKET_TYPE_CONTINUATION,
PINOS_PACKET_TYPE_ADD_MEM,
PINOS_PACKET_TYPE_REMOVE_MEM,
PINOS_PACKET_TYPE_START,
PINOS_PACKET_TYPE_STREAMING,
PINOS_PACKET_TYPE_STOP,
PINOS_PACKET_TYPE_STOPPED,
PINOS_PACKET_TYPE_DRAIN,
PINOS_PACKET_TYPE_DRAINED,
PINOS_PACKET_TYPE_HEADER,
PINOS_PACKET_TYPE_PROCESS_MEM,
PINOS_PACKET_TYPE_REUSE_MEM,
PINOS_PACKET_TYPE_FORMAT_CHANGE,
PINOS_PACKET_TYPE_PROPERTY_CHANGE,
PINOS_PACKET_TYPE_REFRESH_REQUEST,
} PinosPacketType;
/* iterating packets */
struct _PinosBufferIter {
/*< private >*/
gsize x[16];
};
void pinos_buffer_iter_init_full (PinosBufferIter *iter,
PinosBuffer *buffer,
guint32 version);
#define pinos_buffer_iter_init(i,b) pinos_buffer_iter_init_full(i,b, PINOS_BUFFER_VERSION);
gboolean pinos_buffer_iter_next (PinosBufferIter *iter);
void pinos_buffer_iter_end (PinosBufferIter *iter);
PinosPacketType pinos_buffer_iter_get_type (PinosBufferIter *iter);
gpointer pinos_buffer_iter_get_data (PinosBufferIter *iter, gsize *size);
/**
* PinosBufferBuilder:
*/
struct _PinosBufferBuilder {
/*< private >*/
gsize x[16];
};
void pinos_buffer_builder_init_full (PinosBufferBuilder *builder,
guint32 version,
gpointer data,
gsize max_data,
gint *fds,
gint max_fds);
#define pinos_buffer_builder_init_into(b,d,md,f,mf) pinos_buffer_builder_init_full(b, PINOS_BUFFER_VERSION,d,md,f,mf);
#define pinos_buffer_builder_init(b) pinos_buffer_builder_init_into(b, NULL, 0, NULL, 0);
void pinos_buffer_builder_set_flags (PinosBufferBuilder *builder,
PinosBufferFlags flags);
void pinos_buffer_builder_clear (PinosBufferBuilder *builder);
void pinos_buffer_builder_end (PinosBufferBuilder *builder,
PinosBuffer *buffer);
gboolean pinos_buffer_builder_add_empty (PinosBufferBuilder *builder,
PinosPacketType type);
gint pinos_buffer_builder_add_fd (PinosBufferBuilder *builder,
int fd);
/* add-mem packets */
/**
* PinosPacketAddMem:
* @port: the port number
* @id: the unique id of this memory block
* @type: the memory block type
* @fd_index: the index of the fd with the data
* @offset: the offset of the data
* @size: the size of the data
*
* A Packet that contains a memory block used for data transfer.
*/
typedef struct {
guint32 port;
guint32 id;
guint32 type;
gint32 fd_index;
guint64 offset;
guint64 size;
} PinosPacketAddMem;
gboolean pinos_buffer_iter_parse_add_mem (PinosBufferIter *iter,
PinosPacketAddMem *payload);
gboolean pinos_buffer_builder_add_add_mem (PinosBufferBuilder *builder,
PinosPacketAddMem *payload);
/* remove-mem packets */
/**
* PinosPacketRemoveMem:
* @port: the port number
* @id: the unique id of the memory block
*
* Remove a memory block.
*/
typedef struct {
guint32 port;
guint32 id;
} PinosPacketRemoveMem;
gboolean pinos_buffer_iter_parse_remove_mem (PinosBufferIter *iter,
PinosPacketRemoveMem *payload);
gboolean pinos_buffer_builder_add_remove_mem (PinosBufferBuilder *builder,
PinosPacketRemoveMem *payload);
/* header packets */
/**
* PinosPacketHeader
* @flags: header flags
* @seq: sequence number
* @pts: presentation timestamp in nanoseconds
* @dts_offset: offset to presentation timestamp in nanoseconds to get decode timestamp
*
* A Packet that contains the header.
*/
typedef struct {
guint32 port;
guint32 flags;
guint32 seq;
gint64 pts;
gint64 dts_offset;
} PinosPacketHeader;
gboolean pinos_buffer_iter_parse_header (PinosBufferIter *iter,
PinosPacketHeader *payload);
gboolean pinos_buffer_builder_add_header (PinosBufferBuilder *builder,
PinosPacketHeader *payload);
/* process-mem packets */
/**
* PinosPacketProcessMem:
* @id: the mem index to process
* @offset: the offset of the data
* @size: the size of the data
*
* A Packet that contains data in an fd at @fd_index at @offset and with
* @size.
*/
typedef struct {
guint32 port;
guint32 id;
guint64 offset;
guint64 size;
} PinosPacketProcessMem;
gboolean pinos_buffer_iter_parse_process_mem (PinosBufferIter *iter,
PinosPacketProcessMem *payload);
gboolean pinos_buffer_builder_add_process_mem (PinosBufferBuilder *builder,
PinosPacketProcessMem *payload);
/* reuse-mem packets */
/**
* PinosPacketReuseMem:
* @id: the unique id of the memory block to reuse
*
* Release the payload with @id
*/
typedef struct {
guint32 port;
guint32 id;
guint64 offset;
guint64 size;
} PinosPacketReuseMem;
gboolean pinos_buffer_iter_parse_reuse_mem (PinosBufferIter *iter,
PinosPacketReuseMem *payload);
gboolean pinos_buffer_builder_add_reuse_mem (PinosBufferBuilder *builder,
PinosPacketReuseMem *payload);
/* format change packets */
/**
* PinosPacketFormatChange:
* @id: the id of the new format
* @format: the new format
*
* A new format.
*/
typedef struct {
guint32 port;
guint32 id;
const gchar *format;
} PinosPacketFormatChange;
gboolean pinos_buffer_iter_parse_format_change (PinosBufferIter *iter,
PinosPacketFormatChange *payload);
gboolean pinos_buffer_builder_add_format_change (PinosBufferBuilder *builder,
PinosPacketFormatChange *payload);
/* property change packets */
/**
* PinosPacketPropertyChange:
* @key: the key of the property
* @value: the new value
*
* A new property change.
*/
typedef struct {
guint32 port;
const gchar *key;
const gchar *value;
} PinosPacketPropertyChange;
gboolean pinos_buffer_iter_parse_property_change (PinosBufferIter *iter,
guint idx,
PinosPacketPropertyChange *payload);
gboolean pinos_buffer_builder_add_property_change (PinosBufferBuilder *builder,
PinosPacketPropertyChange *payload);
/* refresh request packets */
/**
* PinosPacketRefreshRequest:
* @last_id: last frame seen frame id
* @request_type: the type of the request
* @pts: the timestamp of the requested key frame, 0 = as soon as possible
*
* A refresh request packet. This packet is sent to trigger a new keyframe.
*/
typedef struct {
guint32 port;
guint32 last_id;
guint32 request_type;
gint64 pts;
} PinosPacketRefreshRequest;
gboolean pinos_buffer_iter_parse_refresh_request (PinosBufferIter *iter,
PinosPacketRefreshRequest *payload);
gboolean pinos_buffer_builder_add_refresh_request (PinosBufferBuilder *builder,
PinosPacketRefreshRequest *payload);
#endif
#endif /* __PINOS_BUFFER_H__ */

View file

@ -1,181 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <sys/socket.h>
#include <string.h>
#include <errno.h>
#include <gio/gio.h>
#include "pinos/client/pinos.h"
#include "pinos/client/private.h"
#if 0
gboolean
pinos_io_read_buffer (int fd,
PinosBuffer *buffer,
void *data,
size_t max_data,
int *fds,
size_t max_fds,
GError **error)
{
gssize len;
PinosStackHeader *hdr;
PinosStackBuffer *sb = (PinosStackBuffer *) buffer;
gsize need;
struct cmsghdr *cmsg;
struct msghdr msg = {0};
struct iovec iov[1];
char cmsgbuf[CMSG_SPACE (max_fds * sizeof (int))];
g_assert (sb->refcount == 0);
sb->data = data;
sb->max_size = max_data;
sb->size = 0;
sb->free_data = NULL;
sb->fds = fds;
sb->max_fds = max_fds;
sb->n_fds = 0;
sb->free_fds = NULL;
hdr = sb->data;
/* read header and control messages first */
iov[0].iov_base = hdr;
iov[0].iov_len = sizeof (PinosStackHeader);;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_control = cmsgbuf;
msg.msg_controllen = sizeof (cmsgbuf);
msg.msg_flags = MSG_CMSG_CLOEXEC;
while (TRUE) {
len = recvmsg (fd, &msg, msg.msg_flags);
if (len < 0) {
if (errno == EINTR)
continue;
else
goto recv_error;
}
break;
}
g_assert (len == sizeof (PinosStackHeader));
/* now we know the total length */
need = sizeof (PinosStackHeader) + hdr->length;
if (sb->max_size < need) {
g_warning ("io: realloc receive memory %" G_GSIZE_FORMAT" -> %" G_GSIZE_FORMAT, sb->max_size, need);
sb->max_size = need;
hdr = sb->data = sb->free_data = g_realloc (sb->free_data, need);
}
sb->size = need;
if (hdr->length > 0) {
/* read data */
while (TRUE) {
len = recv (fd, (gchar *)sb->data + sizeof (PinosStackHeader), hdr->length, 0);
if (len < 0) {
if (errno == EINTR)
continue;
else
goto recv_error;
}
break;
}
g_assert (len == hdr->length);
}
/* handle control messages */
for (cmsg = CMSG_FIRSTHDR (&msg); cmsg != NULL; cmsg = CMSG_NXTHDR (&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS)
continue;
sb->n_fds = (cmsg->cmsg_len - ((char *)CMSG_DATA (cmsg) - (char *)cmsg)) / sizeof (int);
memcpy (sb->fds, CMSG_DATA (cmsg), sb->n_fds * sizeof (int));
}
sb->refcount = 1;
sb->magic = PSB_MAGIC;
return TRUE;
/* ERRORS */
recv_error:
{
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
"could not recvmsg: %s", strerror (errno));
return FALSE;
}
}
gboolean
pinos_io_write_buffer (int fd,
PinosBuffer *buffer,
GError **error)
{
PinosStackBuffer *sb = (PinosStackBuffer *) buffer;
gssize len;
struct msghdr msg = {0};
struct iovec iov[1];
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE (sb->n_fds * sizeof (int))];
gint fds_len = sb->n_fds * sizeof (int);
iov[0].iov_base = sb->data;
iov[0].iov_len = sb->size;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_control = cmsgbuf;
msg.msg_controllen = CMSG_SPACE (fds_len);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN (fds_len);
memcpy(CMSG_DATA(cmsg), sb->fds, fds_len);
msg.msg_controllen = cmsg->cmsg_len;
while (TRUE) {
len = sendmsg (fd, &msg, 0);
if (len < 0) {
if (errno == EINTR)
continue;
else
goto send_error;
}
break;
}
g_assert (len == (gssize) sb->size);
return TRUE;
/* ERRORS */
send_error:
{
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
"could not sendmsg: %s", strerror (errno));
return FALSE;
}
}
#endif

View file

@ -20,7 +20,6 @@
#ifndef __PINOS_H__
#define __PINOS_H__
#include <pinos/client/buffer.h>
#include <pinos/client/context.h>
#include <pinos/client/enumtypes.h>
#include <pinos/client/fdmanager.h>

View file

@ -55,42 +55,3 @@ void pinos_subscribe_get_proxy (PinosSubscribe *
GDBusProxy * pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe,
GAsyncResult *res,
GError **error);
#if 0
typedef struct {
guint32 version;
guint32 flags;
guint32 length;
} PinosStackHeader;
typedef struct {
PinosBuffer *next;
gpointer data;
gsize size;
gsize max_size;
gpointer free_data;
gint *fds;
gint n_fds;
gint max_fds;
gpointer free_fds;
gsize magic;
gint refcount;
} PinosStackBuffer;
#define PSB(b) ((PinosStackBuffer *) (b))
#define PSB_MAGIC ((gsize) 5493683301u)
#define is_valid_buffer(b) (b != NULL && \
PSB(b)->magic == PSB_MAGIC)
gboolean pinos_io_read_buffer (int fd,
PinosBuffer *sb,
void *data,
size_t max_data,
int *fds,
size_t max_fds,
GError **error);
gboolean pinos_io_write_buffer (int fd,
PinosBuffer *buffer,
GError **error);
#endif

View file

@ -29,7 +29,6 @@ typedef struct _PinosRingbufferClass PinosRingbufferClass;
typedef struct _PinosRingbufferPrivate PinosRingbufferPrivate;
#include <pinos/client/introspect.h>
#include <pinos/client/buffer.h>
#define PINOS_TYPE_RINGBUFFER (pinos_ringbuffer_get_type ())
#define PINOS_IS_RINGBUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_RINGBUFFER))

View file

@ -22,10 +22,11 @@
#include <glib-object.h>
#include <pinos/client/buffer.h>
#include <pinos/client/context.h>
#include <spa/include/spa/buffer.h>
#include <pinos/client/context.h>
G_BEGIN_DECLS
#define PINOS_TYPE_STREAM (pinos_stream_get_type ())