Ejemplo n.º 1
0
        /// <summary>
        /// Load the GStreamer library and attach it
        /// to the specified window.
        /// </summary>
        public bool Initiate()
        {
            // load the gstreamer library
            IntPtr ptr = gst_binding_init();

            if (ptr == IntPtr.Zero)
            {
                throwError("Failed to load the Gstreamer library", "");
                return(false);
            }
            else
            {
                engine = new HandleRef(this, ptr);
            }


            // set up callbacks
            eos_cb    = new eosCallback(onEos);
            error_cb  = new errorCallback(onError);
            buffer_cb = new bufferCallback(onBuffer);
            info_cb   = new infoCallback(onInfo);
            tag_cb    = new tagCallback(onTag);

            gst_binding_set_eos_cb(engine, eos_cb);
            gst_binding_set_error_cb(engine, error_cb);
            gst_binding_set_buffer_cb(engine, buffer_cb);
            gst_binding_set_info_cb(engine, info_cb);
            gst_binding_set_tag_cb(engine, tag_cb);


            status = MediaStatus.Unloaded;

            return(true);
        }
Ejemplo n.º 2
0
        // Constructor for service.
        // Make sure to include Max Pool Size and Min Pool Size in connection string.
        // Setting these values correctly will improve performance
        public service(
                string connectionString, 
                string configPath = "configuration.json", 
                ErrorLevels err = ErrorLevels.production,
                errorCallback cb = null,
                int pageSize = 256,
                bool log = false
            ) {
            this.connectionString = connectionString;
            this.configuartionFilePath = configPath;
            this.serializer = new JavaScriptSerializer();
            DEFAULT_PAGE_SIZE = pageSize;
            mainCB = cb;
            ersp = new errorResponse(this);
            errorLevel = err;
            alwaysLog = log;
#if profiling
            this.profiler = new Stopwatch();
            this.profiler.Reset();
#endif
            // Read the entire contents of the configuration file
            using (StreamReader fs = new StreamReader(this.configuartionFilePath)) {
                this.configurationFileData = fs.ReadToEnd();
            }

            // Deserialize the config file
            Dictionary<string, object> deserialization = (Dictionary<string, object>)this.serializer.DeserializeObject(this.configurationFileData);

            // Instantiate configuration structure
            this.configurationStructure = new serviceConfiguration();

            // The following block reads all of the important values from the base object in the config JSON
            this.configurationStructure.tenantIdentityField = deserialization["tenantIdentifier"].ToString();
            this.configurationStructure.authenticationTable = deserialization["authenticationField"].ToString().Split(new char[] {'.'})[0];
            this.configurationStructure.authenticationField = deserialization["authenticationField"].ToString().Split(new char[] {'.'})[1];
            this.configurationStructure.defaultAccessRead = (bool)deserialization["accessRead"];
            this.configurationStructure.defaultAccessWrite = (bool)deserialization["accessWrite"];
            this.configurationStructure.tables = new List<table>();

            // Pulls the list of tables out of the config JSON
            object[] tables = (object[])deserialization["tables"];

            // Iterate over tables and interpret data
            for (int i = 0; i < tables.Length; i++) {


                // The following block pulls the current table iteration out of the structure
                Dictionary<string, object> kvp = (Dictionary<string, object>)tables[i];
                table ct = new table();
                ct.tableName = kvp["table"].ToString();

                // Attempts to read some overarching config values for the table
                try {
                    ct.read = (bool)kvp["accessRead"];
                } catch (Exception ex) {
                    ct.read = this.configurationStructure.defaultAccessRead;
                }
                try {
                    ct.write = (bool)kvp["accessWrite"];
                } catch (Exception ex) {
                    ct.write = this.configurationStructure.defaultAccessWrite;
                }

                // Iterate over the fields in the table an read their configuration perameters
                object[] fields = (object[])kvp["fields"];
                ct.fields = new List<field>();
                for (int j = 0; j < fields.Length; j++) {
                    Dictionary<string, object> kvpf = (Dictionary<string, object>)fields[j];
                    field cf = new field();
                    cf.fieldName = kvpf["field"].ToString();
                    cf.fieldType = kvpf["DotNetType"].ToString();
                    try {
                        cf.isForeignKey = (bool)kvpf["foreignKey"];
                    } catch (Exception ex) {
                        cf.isForeignKey = false;
                    }
                    try {
                        cf.isPrimaryKey = (bool)kvpf["primaryKey"];
                    } catch (Exception ex) {
                        cf.isPrimaryKey = false;
                    }
                    try {
                        cf.isTenantID = (bool)kvpf["tenantID"];
                    } catch (Exception ex) {
                        cf.isTenantID = false;
                    }
                    try {
                        cf.read = (bool)kvpf["accessRead"];
                    } catch (Exception ex) {
                        cf.read = ct.read;
                    }
                    try {
                        cf.write = (bool)kvpf["accessWrite"];
                    } catch (Exception ex) {
                        cf.write = ct.write;
                    }
                    if (cf.isForeignKey) {
                        try {
                            cf.foreignTable = (string)kvpf["foreignTable"];
                        } catch (Exception ex) {
                            // Do nothing because this means that the configuration is wrong but we don't want to break the server due to a small configuration error.
                            // TODO:incorporate this error into an error reporting mechanism.
                            // This mechanim will allow the programmer to specify whether they want soft fails or hard fails.
                        }
                    }
                    ct.fields.Add(cf);
                }
                this.configurationStructure.tables.Add(ct);
            }
        }
Ejemplo n.º 3
0
 static extern void gst_binding_set_error_cb(HandleRef play, errorCallback cb);
Ejemplo n.º 4
0
 static extern void gst_binding_set_error_cb(HandleRef play, errorCallback cb);
Ejemplo n.º 5
0
        /// <summary>
        /// Load the GStreamer library and attach it
        /// to the specified window.
        /// </summary>
        public bool Initiate(ulong x_window_id)
        {
            // load the gstreamer library
            IntPtr ptr = gst_binding_init (x_window_id);

            if(ptr == IntPtr.Zero)
            {
                throwError ("Failed to load the Gstreamer library", "");
                return false;
            }
            else engine = new HandleRef (this, ptr);

            // set up callbacks
            eos_cb = new eosCallback (onEos);
            error_cb = new errorCallback (onError);
            buffer_cb = new bufferCallback (onBuffer);
            info_cb = new infoCallback (onInfo);
            tag_cb = new tagCallback (onTag);

            gst_binding_set_eos_cb (engine, eos_cb);
            gst_binding_set_error_cb (engine, error_cb);
            gst_binding_set_buffer_cb (engine, buffer_cb);
            gst_binding_set_info_cb (engine, info_cb);
            gst_binding_set_tag_cb (engine, tag_cb);

            status = MediaStatus.Stopped;
            return true;
        }