/** * overrides the default buffer allocation for output port to allow * pad_alloc'ing from the srcpad */ static GstBuffer * buffer_alloc (GOmxPort *port, gint len) { GstOmxBaseSrc *self = port->core->object; GstBaseSrc *gst_base = GST_BASE_SRC (self); GstBuffer *buf; GstFlowReturn ret; check_settings (self->out_port, gst_base->srcpad); ret = gst_pad_alloc_buffer_and_set_caps ( gst_base->srcpad, GST_BUFFER_OFFSET_NONE, len, GST_PAD_CAPS (gst_base->srcpad), &buf); if (ret == GST_FLOW_OK) return buf; return NULL; }
int main(int argc, char** argv) { if ( argc < 2 ) { std::cerr << "Arg is missing" << std::endl; usage(); return EXIT_FAILURE; } /* * Dealing with settings */ m_settings settings; if ( argc > 2 ) { int c; while ((c = getopt (argc, argv, "h:u:p:d:s:f:")) != -1 ) { switch (c) { case 'h': settings.insert("hostname", optarg); break; case 'u': settings.insert("username", optarg); break; case 'p': settings.insert("password", optarg); break; case 'd': settings.insert("driver", optarg); break; case 's': settings.insert("database", optarg); break; case 'f': settings.insert("import_type", optarg); break; case '?': return EXIT_FAILURE; } } } else { QCoreApplication::setOrganizationName("nsrl_toolkit"); QCoreApplication::setApplicationName("rds_bench"); } if ( check_settings(settings) == false ) return EXIT_FAILURE; QSqlDatabase db; qint64 rows = 0; qint64 total_time = 0; // Create the db object if ( init_db(db, settings) == false ) return EXIT_FAILURE; QSqlQuery query_1(db); QSqlQuery query_2(db); db.transaction(); if ( db.driverName().compare("PGSQL") == 0 ) start_pgsql(rows, total_time, db, query_1, query_2); if ( db.driverName().compare("MYSQL") == 0 ) start_mysql(rows, total_time, db, query_1, query_2); db.rollback(); /* * Ending */ if ( rows > 0 ) { std::cout << "Elapsed time: " << total_time << " milliseconds (" << (float)total_time / 1000.0 << " seconds)" << std::endl; std::cout << "Processed lines: " << rows << std::endl; std::cout << "Speed: " << (float)rows / ((float)total_time / 1000.0 ) << " rows / second" << std::endl; } else { std::cout << "No line returned" << std::endl; } // Close and destroy the db object db.close(); QSqlDatabase::removeDatabase(settings.value("driver")); return EXIT_SUCCESS; }