- count = fread(stream + BITSTREAM_HEADER_SIZE,
- length - BITSTREAM_HEADER_SIZE, 1, file);
- if (count != 1) {
- sr_err("Failed to read bitstream file: %s.", g_strerror(errno));
- fclose(file);
+ count = sr_resource_read(ctx, &rbf, stream + BITSTREAM_HEADER_SIZE,
+ length - BITSTREAM_HEADER_SIZE);
+ sr_resource_close(ctx, &rbf);
+
+ if (count != length - BITSTREAM_HEADER_SIZE) {
+ sr_err("Failed to read bitstream '%s'.", name);