* System No. System nomenclature Form of scanning Frame rate Embedded Audio MLT profile Linsys board support (model)
* SD PAL 720 × 576/50/I interlaced 25 HZ 8 x AES (16 channels) dv_pal 180,145,159,107
* SD PAL 720 × 576/50/I interlaced 25 HZ 4 x AES (8 channels) dv_pal 193
- * SD NTSC 720 × 480/59.94/I interlaced 30000/1001 ~ 29.97 HZ 8 x AES (16 channels) sdi_486i_5994 TODO:180,145,159,107
- * SD NTSC 720 × 480/59.94/I interlaced 30000/1001 ~ 29.97 HZ 4 x AES (8 channels) sdi_486i_5994 193
+ * SD NTSC 720 × 486/59.94/I interlaced 30000/1001 ~ 29.97 HZ 8 x AES (16 channels) sdi_486i_5994 TODO:180,145,159,107
+ * SD NTSC 720 × 486/59.94/I interlaced 30000/1001 ~ 29.97 HZ 4 x AES (8 channels) sdi_486i_5994 193
*
**/
#include <framework/mlt_frame.h>
#include <framework/mlt_profile.h>
#include <framework/mlt_log.h>
+#include <framework/mlt_events.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <stdint.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#ifdef WITH_JPEG
// for JPEG output
// our audio channel pair for this frame
int16_t audio_buffer[MAX_AUDIO_STREAMS][MAX_AUDIO_SAMPLES]; // The SDI audio channel pairs for this frame
- char *video_fmt_name; // 1080i25, 1080p25, 576i50, 480i2997, ...
+ char *video_fmt_name; // 1080i25, 1080p25, 576i50, 486i2997, ...
};
mlt_consumer consumer_SDIstream_init(mlt_profile profile, mlt_service_type type, const char *id, char *arg) {
// Create the consumer object
- consumer_SDIstream this = calloc(sizeof(struct consumer_SDIstream_s), 1);
+ consumer_SDIstream this = calloc( 1, sizeof(struct consumer_SDIstream_s) );
// If malloc and consumer init ok
if (this != NULL && mlt_consumer_init(&this->parent, this, profile) == 0) {
this->audio_buffer[i][j] = j;
}
}
+
+ mlt_events_register( MLT_CONSUMER_PROPERTIES(parent), "consumer-fatal-error", NULL );
// Return the consumer produced
return parent;
int counter = 0; // each second we save a Jpeg
- // set blanking flag; is not nessary we write no own blanking(HANC) for HD board ASSY 193
- if (mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "blanking") != NULL) {
- // set value
- if (strcmp(strdup(mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "blanking")), "false")) {
- this->blanking = 1;
- } else if (strcmp(strdup(mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "blanking")), "true")) {
- this->blanking = 0;
- } else {
- this->blanking = 1;
- }
- } else {
- // set default value without HD board, also with blanking
- this->blanking = 1;
- }
-
// set properties (path) for device files
if (mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "dev_video") != NULL) {
this->device_file_video = strdup(mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "dev_video"));
}
}
+ // Set additional device file defaults
+ struct stat st;
+ int fd = -1;
+ if (this->device_file_video)
+ fd = stat(this->device_file_video, &st);
+ if (fd == -1) {
+ if (this->device_file_video)
+ free(this->device_file_video);
+ this->device_file_video = strdup("/dev/sdivideotx0");
+ } else {
+ close(fd);
+ }
+ if (this->device_file_audio) {
+ fd = stat(this->device_file_audio, &st);
+ if (fd == -1) {
+ if (this->device_file_audio)
+ free(this->device_file_audio);
+ this->device_file_audio = strdup("/dev/sdiaudiotx0");
+ } else {
+ close(fd);
+ }
+ } else if (this->device_file_video &&
+ strstr(this->device_file_video, "sdivideotx")) {
+ if (this->device_file_audio)
+ free(this->device_file_audio);
+ this->device_file_audio = strdup("/dev/sdiaudiotx0");
+ }
+
+ // set blanking flag; is not nessary we write no own blanking(HANC) for HD board ASSY 193
+ if (mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "blanking")) {
+ // set value
+ if (!strcmp( mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "blanking"), "false")) {
+ this->blanking = 0;
+ } else if (!strcmp( mlt_properties_get(MLT_CONSUMER_PROPERTIES( consumer ), "blanking"), "true")) {
+ this->blanking = 1;
+ } else {
+ this->blanking = mlt_properties_get_int(MLT_CONSUMER_PROPERTIES( consumer ), "blanking");
+ }
+ } else if (this->device_file_video && strstr(this->device_file_video, "sdivideotx")) {
+ this->blanking = 0;
+ } else {
+ // set default value without HD board, also with blanking
+ this->blanking = 1;
+ }
+
// Define a frame pointer
mlt_frame frame;
// Tell the framework how we want our audio and video
int frequency = this->audio_format.sample_rate;
- int channels = 0;
- int samples = mlt_sample_calculator(fps, frequency, count++);
+ int channels = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES(consumer), "channels" );
+ int samples;
// set number of audio channels, linsys vidport model 193 is limited to 8 channels (4AES frames)
this->audio_format.channels = 8; /* 0,2,4,6,8 */
this->audio_format.sample_rate = 48000;
this->pix_fmt = mlt_image_yuv422;
- if (!sdi_init(this->device_file_video, this->device_file_audio, this->blanking, mlt_service_profile((mlt_service) consumer), &this->audio_format)) {
- exit(0);
+ if (this->device_file_video && this->device_file_audio &&
+ !sdi_init(this->device_file_video, this->device_file_audio, this->blanking, mlt_service_profile((mlt_service) consumer), &this->audio_format)) {
+ mlt_log_fatal( MLT_CONSUMER_SERVICE(consumer), "failed to initialize\n" );
+ mlt_events_fire( MLT_CONSUMER_PROPERTIES(consumer), "consumer-fatal-error", NULL );
}
uint8_t *video_buffer;
mlt_frame_get_image(frame, &video_buffer, &this->pix_fmt, &this->width, &this->height, 1);
// Get the audio from this frame and save it to our audio_buffer
+ samples = mlt_sample_calculator(fps, frequency, count++);
mlt_frame_get_audio(frame, (void**) &audio_buffer_tmp, &this->audio_format.aformat, &frequency, &channels, &samples);
this->audio_format.sample_rate = frequency;
} else if (save_jpegs > 0) {
counter++;
}
+ mlt_events_fire(MLT_CONSUMER_PROPERTIES( consumer ), "consumer-frame-show", frame, NULL );
} else {
mlt_log_warning(MLT_CONSUMER_SERVICE(consumer), "Videobuffer was NULL, skipping playout!\n");
}