Skip to content

Instantly share code, notes, and snippets.

View yashi's full-sized avatar

Yasushi SHOJI yashi

View GitHub Profile
@yashi
yashi / mem1.c
Last active December 11, 2015 09:30
mem = gst_allocator_alloc(NULL, 3, NULL);
size = gst_memory_get_sizes(mem, NULL, &maxsize);
g_print("mem 1:\n");
g_print(" size: %" G_GSIZE_FORMAT "\n", size);
g_print(" maxsize: %" G_GSIZE_FORMAT "\n", maxsize);
gst_memory_map(mem, &info, GST_MAP_WRITE);
memcpy(info.data, "abc", 3);
gst_memory_unmap(mem, &info);
gst_buffer_insert_memory(buf, -1, mem);
@yashi
yashi / mem2.c
Created December 11, 2015 09:29
mem = gst_allocator_alloc(NULL, 6, NULL);
size = gst_memory_get_sizes(mem, NULL, &maxsize);
g_print("mem 2:\n");
g_print(" size: %" G_GSIZE_FORMAT "\n", size);
g_print(" maxsize: %" G_GSIZE_FORMAT "\n", maxsize);
gst_memory_map(mem, &info, GST_MAP_WRITE);
memcpy(info.data, "12345", 6);
gst_memory_unmap(mem, &info);
gst_buffer_insert_memory(buf, -1, mem);
@yashi
yashi / gpio.c
Last active January 10, 2016 15:13
gpio test code with glib
/*
* Library for Linux GPIO Sysfs Interface with Glib library
*
* Copyright (c) 2016 Yasushi SHOJI <yashi@atmark-techno.com>
*
* The MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
@yashi
yashi / a.c
Created December 28, 2016 07:49
GstAdapter example 1
#include <gst/base/gstadapter.h>
int main(int argc, char *argv[])
{
GstAdapter *a;
GstBuffer *b;
gst_init(&argc, &argv);
a = gst_adapter_new();
@yashi
yashi / take_vs_get.c
Created December 28, 2016 07:50
GstAdapter example 2
#include <gst/base/gstadapter.h>
int main(int argc, char *argv[])
{
GstAdapter *a;
GstBuffer *b, *b1, *b2;
gst_init(&argc, &argv);
a = gst_adapter_new();
@yashi
yashi / map.c
Created December 28, 2016 07:51
GstAdapter example 3
#include <stdio.h>
#include <gst/base/gstadapter.h>
int main(int argc, char *argv[])
{
GstAdapter *a;
GstBuffer *b;
char *buf;
char const * p;
GstMapInfo i;
@yashi
yashi / libc.c
Last active January 4, 2017 10:27
GNU Libc Regex
/* -*- compile-command: "gcc -Wall -Wextra -g libc.c" -*- */
#include <regex.h>
#include <string.h>
#include <stdio.h>
int main(void)
{
regex_t re;
const char *pattern = "^b";
int ret;
@yashi
yashi / pcre.c
Last active January 27, 2021 08:37
PCRE Regex
/* -*- compile-command: "gcc -Wall -Wextra -g $(pkg-config --cflags --libs libpcre2-8) pcre.c" -*- */
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#include <string.h>
#include <stdio.h>
int main(void)
{
pcre2_code *re;
PCRE2_SPTR pattern = (PCRE2_SPTR)"^b";
@yashi
yashi / re2.cpp
Last active January 4, 2017 10:28
RE2 Regex
// -*- compile-command: "g++ -Wall -Wextra -g -lre2 re2.cc" -*-
#include <re2/re2.h>
#include <string.h>
#include <stdio.h>
using namespace re2;
int main()
{
const char *pattern = "^b";
@yashi
yashi / gst-dynamic-pad.c
Last active May 10, 2021 02:25
An Example for GStreamer Dynamic Pad (Decodebin)
#include <gst/gst.h>
static gboolean bus_call (G_GNUC_UNUSED GstBus *bus, GstMessage *msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End of stream\n");