Exemple #1
0
HRESULT MfMediaStream::Create_(IMFMediaStreamPtr& ptr_stream)
{
    ptr_stream_ = ptr_stream;
    HRESULT hr = ptr_stream_->QueryInterface(IID_IMFMediaEventGenerator,
        reinterpret_cast<void**>(&ptr_event_queue_));
    if (FAILED(hr))
    {
        DBGLOG("ERROR, failed to obtain stream event generator" << HRLOG(hr)
            << " returning E_FAIL.");
        return E_FAIL;
    }
    IMFStreamDescriptorPtr ptr_desc;
    hr = ptr_stream->GetStreamDescriptor(&ptr_desc);
    if (FAILED(hr))
    {
        DBGLOG("ERROR, GetStreamDescriptor failed" << HRLOG(hr));
        return hr;
    }
    hr = get_media_type(ptr_desc, &ptr_media_type_);
    if (FAILED(hr))
    {
        DBGLOG("ERROR, get_media_type failed" << HRLOG(hr));
        return hr;
    }
    hr = stream_event_.Create();
    if (FAILED(hr))
    {
        DBGLOG("ERROR, stream event creation failed" << HRLOG(hr));
        return hr;
    }
    return hr;
}
Exemple #2
0
/* test recording (loop test over BtSinkBinRecordFormat */
static void
test_bt_sink_bin_record (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  if (!bt_sink_bin_is_record_format_supported (_i))
    return;
  // see GST_BUG_733031
  if (_i == 3 || _i == 6)
    return;
#if !GST_CHECK_VERSION (1,8,0)
  if (_i == 5 || _i == 7)
    return;
#endif

  make_new_song ( /*silence */ 4);
  GstElement *sink_bin = get_sink_bin ();
  GEnumClass *enum_class =
      g_type_class_peek_static (BT_TYPE_SINK_BIN_RECORD_FORMAT);
  GEnumValue *enum_value = g_enum_get_value (enum_class, _i);
  gchar *filename = make_tmp_song_path ("record", enum_value->value_name);
  g_object_set (sink_bin,
      "mode", BT_SINK_BIN_MODE_RECORD,
      "record-format", _i, "record-file-name", filename, NULL);

  GST_INFO ("-- act --");
  GST_INFO ("act: == %s ==", filename);
  bt_song_play (song);
  run_main_loop_until_eos ();
  bt_song_stop (song);
  g_object_set (sink_bin, "mode", BT_SINK_BIN_MODE_PLAY, NULL);

  GST_INFO ("-- assert --");
  GST_INFO ("assert: == %s ==", filename);
  fail_unless (g_file_test (filename, G_FILE_TEST_IS_REGULAR));
  GStatBuf st;
  g_stat (filename, &st);
  ck_assert_int_gt (st.st_size, 0);
  ck_assert_str_eq_and_free (get_media_type (filename), media_types[_i]);

  GST_INFO ("-- cleanup --");
  g_free (filename);
  gst_object_unref (sink_bin);
  BT_TEST_END;
}
Exemple #3
0
/*
 * Print adapter configuration information
 * 
 * Arguments:
 *	si	pointer to a struct air_cfg_rsp
 *
 * Returns:
 *	none
 *
 */
void
print_cfg_info(struct air_cfg_rsp *si)
{
	const char	*adapter, *bus, *media, *vendor;

	/*
	 * Print a header if it hasn't been done yet.
	 */
	if (!cfg_hdr) {
		printf(CFG_HDR);
		cfg_hdr = 1;
	}

	/*
	 * Format the vendor name and adapter type
	 */
	vendor = get_vendor(si->acp_vendor);
	adapter = get_adapter(si->acp_device);

	/*
	 * Format the communications medium
	 */
	media = get_media_type(si->acp_media);
	bus = get_bus_type(si->acp_bustype);

	/*
	 * Print the ARP server information
	 */
	printf("%-8s  %-8s  %-8s  %-14s  %-4s  %ld\n",
			si->acp_intf,
			vendor,
			adapter,
			media,
			bus,
			si->acp_serial);
	printf("    MAC address = %s\n",
			format_mac_addr(&si->acp_macaddr));
	printf("    Hardware version = %s\n", si->acp_hard_vers);
	printf("    Firmware version = %s\n", si->acp_firm_vers);
}
Exemple #4
0
/*
 * Initialize device for track-at-once mode of writing. All of the data will
 * need to be written to the track without interruption.
 * This initialized TAO by setting page code 5 and speed.
 */
void
write_init(int mode)
{
	(void) printf(gettext("Initializing device"));
	if (simulation)
		(void) printf(gettext("(Simulation mode)"));
	print_n_flush("...");

	get_media_type(target->d_fd);

	/* DVD- requires DAO mode */
	if (device_type == DVD_MINUS) {
		write_mode = DAO_MODE;
	}

	/* DVD+ and DVD- have no support for AUDIO, bail out */
	if ((mode == TRACK_MODE_AUDIO) && (device_type != CD_RW)) {
		err_msg(gettext("Audio mode is only supported for CD media\n"));
		exit(1);
	}
	if (simulation &&
	    check_device(target, CHECK_MEDIA_IS_NOT_BLANK) &&
	    !check_device(target, CHECK_MEDIA_IS_NOT_ERASABLE) &&
	    device_type != DVD_PLUS_W) {
		/*
		 * If we were in simulation mode, and media wasn't blank,
		 * but medium was erasable, then cdrw goes to erase the
		 * contents of the media after the simulation writing in order
		 * to cleanup the ghost TOC (see write_fini() calls blank()).
		 * This is bad because it removes existing data if media was
		 * multi-session. Therefore, we no longer allow simulation
		 * writing if such condition is met. we don't blank the DVD+RW
		 * media, so DVD+RWs are fine.
		 */
		err_msg(gettext(
		    "Cannot perform simulation for non-blank media\n"));
		exit(1);
	}

	if (!prepare_for_write(target, mode, simulation, keep_disc_open)) {
		/* l10n_NOTE : 'failed' as in Initializing device...failed  */
		(void) printf(gettext("failed.\n"));
		err_msg(gettext("Cannot initialize device for write\n"));
		exit(1);
	}
	/* l10n_NOTE : 'done' as in "Initializing device...done"  */
	(void) printf(gettext("done.\n"));

	/* if speed change option was used (-p) then try to set the speed */
	if (requested_speed != 0) {
		if (verbose)
			(void) printf(gettext("Trying to set speed to %dX.\n"),
			    requested_speed);
		if (target->d_speed_ctrl(target, SET_WRITE_SPEED,
		    requested_speed) == 0) {
			err_msg(gettext("Unable to set speed.\n"));
			exit(1);
		}
		if (verbose) {
			int speed;
			speed = target->d_speed_ctrl(target,
			    GET_WRITE_SPEED, 0);
			if (speed == requested_speed) {
				(void) printf(gettext("Speed set to %dX.\n"),
				    speed);
			} else if (speed == 0) {
				(void) printf(gettext("Could not obtain "
				    "current Write Speed.\n"));
			} else {
				(void) printf(
				gettext("Speed set to closest approximation "
				    "of %dX allowed by device (%dX).\n"),
				    requested_speed, speed);
			}
		}
	}
}
Exemple #5
0
void
info(void)
{
	uchar_t *toc, *p, *conf;
	int ret, toc_size;
	uint_t bsize;
	size_t cap = 0;
	char *msg;
	struct track_info *ti;

	msg = gettext("Cannot read Table of contents\n");

	get_media_type(target->d_fd);

	(void) printf(gettext("\nDevice : %.8s %.16s\n"),
	    &target->d_inq[8], &target->d_inq[16]);
	(void) printf(gettext("Firmware : Rev. %.4s (%.12s)\n"),
	    &target->d_inq[32], &target->d_inq[36]);

	if (check_device(target, CHECK_DEVICE_NOT_READY)) {
		(void) check_device(target, CHECK_NO_MEDIA |
		    EXIT_IF_CHECK_FAILED);
		(void) check_device(target, CHECK_DEVICE_NOT_READY |
		    EXIT_IF_CHECK_FAILED);
	}

	if (verbose != 0) {
		/*
		 * Determine the media type by reading the active profile
		 * from the profile list.
		 */
		(void) printf(gettext("Media Type : "));

		conf = (uchar_t *)my_zalloc(MMC_FTR_HDR_LEN);

		if (get_configuration(target->d_fd, MMC_FTR_PRFL_LIST,
		    MMC_FTR_HDR_LEN, conf))
			print_profile_name(read_scsi16(&conf[6]), 0, 1);
		else
			(void) printf(gettext("UNKNOWN\n"));

		free(conf);

		/*
		 * Get the start address of the last possible lead out.
		 */
		cap = get_last_possible_lba(target);

		/*
		 * The start address of the last possible leadout will only
		 * be zero if the disc is full or this drive does not support
		 * this method of determining capacity.
		 */
		if (cap == 0)
			cap = read_format_capacity(target->d_fd, &bsize);

		/*
		 * Since both methods of determining the capacity of the
		 * media count the correct number of blocks, just multiply
		 * the capacity by the block size.
		 */
		cap *= target->d_blksize;

		if (device_type == CD_RW) {
			(void) printf(gettext("Media Capacity : %.2f MB "),
			    ((double)cap/ONE_MB_BASE2));
		} else {
			/*
			 * For DVD's make sure we print out "Formatted Media
			 * Capacity". Don't do this for CD-RWs as only
			 * DVDs are formatted.
			 */
			(void) printf(gettext("Formatted Media Capacity : "
			    "%.2f GB "), ((double)cap/ONE_GB_BASE10));
		}

		cap /= target->d_blksize;
		(void) printf(gettext("(%u blocks)\n"), (uint_t)cap);
	}

	if (!check_device(target, CHECK_MEDIA_IS_NOT_BLANK)) {
		(void) printf(gettext("Media is blank\n"));
		exit(0);
	}

	/*  Find out the number of entries in the toc */
	toc = (uchar_t *)my_zalloc(12);
	if (!read_toc(target->d_fd, 0, 1, 4, toc)) {
		err_msg(msg);
	} else {
		toc_size = 256*toc[0] + toc[1] + 2;
		free(toc);

		/* allocate enough space for each track entry */
		toc = (uchar_t *)my_zalloc(toc_size);

		if (!read_toc(target->d_fd, 0, 1, toc_size, toc)) {
			err_msg(msg);
			exit(1);
		}
		(void) printf("\n");

		/* l10n_NOTE : Preserve column numbers of '|' character */
		(void) printf(gettext("Track No. |Type    |Start address\n"));
		(void) printf("----------+--------+-------------\n");


		/* look at each track and display it's type. */

		for (p = &toc[4]; p < (toc + toc_size); p += 8) {
			if (p[2] != 0xAA)
				(void) printf(" %-3d      |", p[2]);
			else
				(void) printf("Leadout   |");
			(void) printf("%s   |", (p[1] & 4) ? gettext("Data ") :
			    gettext("Audio"));
			(void) printf("%u\n", read_scsi32(&p[4]));
		}
	}
	(void) printf("\n");
	ret = read_toc(target->d_fd, 1, 0, 12, toc);
	if ((ret == 0) || (toc[1] != 0x0a))
		/* For ATAPI drives or old Toshiba drives */
		ret = read_toc_as_per_8020(target->d_fd, 1, 0, 12, toc);

	if (ret && (toc[1] == 0x0a)) {
		(void) printf(gettext("Last session start address: %u\n"),
		    read_scsi32(&toc[8]));
	}
	free(toc);
	ti = (struct track_info *)my_zalloc(sizeof (struct track_info));

	if (build_track_info(target, -1, ti) && (ti->ti_flags & TI_NWA_VALID)) {
		(void) printf(gettext("Next writable address: %u\n"),
		    ti->ti_nwa);
	}
	free(ti);
	exit(0);
}
static gboolean
bind_and_exec (sqlite3 *db,
	       const gchar *sql,
	       const gchar *source_id,
	       const gchar *media_id,
	       GList *col_names,
	       GList *keys,
	       GrlMedia *media)
{
  gint r;
  const gchar *char_value;
  gint int_value;
  double double_value;
  GList *iter_names, *iter_keys;
  guint count;
  sqlite3_stmt *stmt;

  /* Create statement from sql */
  GRL_DEBUG ("%s", sql);
  r = sqlite3_prepare_v2 (db, sql, strlen (sql), &stmt, NULL);

  if (r != SQLITE_OK) {
    GRL_WARNING ("Failed to update metadata for '%s - %s': %s",
                     source_id, media_id, sqlite3_errmsg (db));
    sqlite3_finalize (stmt);
    return FALSE;
  }

  /* Bind media type */
  sqlite3_bind_int (stmt, 1, get_media_type (media));

  /* Bind column values */
  count = 2;
  iter_names = col_names;
  iter_keys = keys;
  while (iter_names) {
    if (iter_names->data) {
      GrlKeyID key = GRLPOINTER_TO_KEYID (iter_keys->data);
      if (key == GRL_METADATA_KEY_RATING) {
	double_value = grl_media_get_rating (media);
	sqlite3_bind_double (stmt, count, double_value);
      } else if (key == GRL_METADATA_KEY_PLAY_COUNT) {
	int_value = grl_media_get_play_count (media);
	sqlite3_bind_int (stmt, count, int_value);
      } else if (key == GRL_METADATA_KEY_LAST_POSITION) {
	int_value = grl_media_get_last_position (media);
	sqlite3_bind_int (stmt, count, int_value);
      } else if (key == GRL_METADATA_KEY_LAST_PLAYED) {
	char_value = grl_media_get_last_played (media);
	sqlite3_bind_text (stmt, count, char_value, -1, SQLITE_STATIC);
      } else if (key == GRL_METADATA_KEY_FAVOURITE) {
        int_value = (gint) grl_media_get_favourite (media);
        sqlite3_bind_int (stmt, count, int_value);
      }
      count++;
    }
    iter_keys = g_list_next (iter_keys);
    iter_names = g_list_next (iter_names);
  }

  sqlite3_bind_text (stmt, count++, source_id, -1, SQLITE_STATIC);
  sqlite3_bind_text (stmt, count++, media_id, -1, SQLITE_STATIC);

  /* execute query */
  while ((r = sqlite3_step (stmt)) == SQLITE_BUSY);

  sqlite3_finalize (stmt);

  return (r == SQLITE_DONE);
}
Exemple #7
0
static int
get_attrs(disk_t *dp, int fd, nvlist_t *attrs)
{
	struct	dk_minfo minfo;
	struct	dk_geom	geometry;

	if (fd < 0) {
		return (ENODEV);
	}

	bzero(&minfo, sizeof (struct dk_minfo));

	/* The first thing to do is read the media */
	if (!media_read_info(fd, &minfo)) {
		return (ENODEV);
	}

	if (partition_has_fdisk(dp, fd)) {
		if (nvlist_add_boolean(attrs, DM_FDISK) != 0) {
			return (ENOMEM);
		}
	}

	if (dp->removable) {
		if (nvlist_add_boolean(attrs, DM_REMOVABLE) != 0) {
			return (ENOMEM);
		}

		if (nvlist_add_boolean(attrs, DM_LOADED) != 0) {
			return (ENOMEM);
		}
	}

	if (nvlist_add_uint64(attrs, DM_SIZE, minfo.dki_capacity) != 0) {
		return (ENOMEM);
	}

	if (nvlist_add_uint32(attrs, DM_BLOCKSIZE, minfo.dki_lbsize) != 0) {
		return (ENOMEM);
	}

	if (nvlist_add_uint32(attrs, DM_MTYPE,
	    get_media_type(minfo.dki_media_type)) != 0) {
		return (ENOMEM);
	}

	/* only for disks < 1TB  and x86 */
#if defined(i386) || defined(__amd64)
	if (ioctl(fd, DKIOCG_PHYGEOM, &geometry) >= 0) {
#else
	/* sparc call */
	if (ioctl(fd, DKIOCGGEOM, &geometry) >= 0) {
#endif
		struct extvtoc	vtoc;

		if (nvlist_add_uint64(attrs, DM_START, 0) != 0) {
			return (ENOMEM);
		}
		if (nvlist_add_uint64(attrs, DM_NACCESSIBLE,
		    geometry.dkg_ncyl * geometry.dkg_nhead * geometry.dkg_nsect)
		    != 0) {
			return (ENOMEM);
		}
		if (nvlist_add_uint32(attrs, DM_NCYLINDERS, geometry.dkg_ncyl)
		    != 0) {
			return (ENOMEM);
		}
		if (nvlist_add_uint32(attrs, DM_NPHYSCYLINDERS,
		    geometry.dkg_pcyl) != 0) {
			return (ENOMEM);
		}
		if (nvlist_add_uint32(attrs, DM_NALTCYLINDERS,
		    geometry.dkg_acyl) != 0) {
			return (ENOMEM);
		}
		if (nvlist_add_uint32(attrs, DM_NHEADS,
		    geometry.dkg_nhead) != 0) {
			return (ENOMEM);
		}
		if (nvlist_add_uint32(attrs, DM_NSECTORS, geometry.dkg_nsect)
		    != 0) {
			return (ENOMEM);
		}
		if (nvlist_add_uint32(attrs, DM_NACTUALCYLINDERS,
		    geometry.dkg_ncyl) != 0) {
			return (ENOMEM);
		}

		if (read_extvtoc(fd, &vtoc) >= 0 && vtoc.v_volume[0] != 0) {
			char	label[LEN_DKL_VVOL + 1];

			(void) snprintf(label, sizeof (label), "%.*s",
			    LEN_DKL_VVOL, vtoc.v_volume);
			if (nvlist_add_string(attrs, DM_LABEL, label) != 0) {
				return (ENOMEM);
			}
		}

	} else {
		/* check for disks > 1TB for accessible size */
		struct dk_gpt	*efip;

		if (efi_alloc_and_read(fd, &efip) >= 0) {
			diskaddr_t	p8size = 0;

			if (nvlist_add_boolean(attrs, DM_EFI) != 0) {
				return (ENOMEM);
			}
			if (nvlist_add_uint64(attrs, DM_START,
			    efip->efi_first_u_lba) != 0) {
				return (ENOMEM);
			}
			/* partition 8 is reserved on EFI labels */
			if (efip->efi_nparts >= 9) {
				p8size = efip->efi_parts[8].p_size;
			}
			if (nvlist_add_uint64(attrs, DM_NACCESSIBLE,
			    (efip->efi_last_u_lba - p8size) -
			    efip->efi_first_u_lba) != 0) {
				efi_free(efip);
				return (ENOMEM);
			}
			efi_free(efip);
		}
	}
	return (0);
}

static int
get_media_type(uint_t media_type)
{
	switch (media_type) {
	case DK_UNKNOWN:
		return (DM_MT_UNKNOWN);
	case DK_MO_ERASABLE:
		return (DM_MT_MO_ERASABLE);
	case DK_MO_WRITEONCE:
		return (DM_MT_MO_WRITEONCE);
	case DK_AS_MO:
		return (DM_MT_AS_MO);
	case DK_CDROM:
		return (DM_MT_CDROM);
	case DK_CDR:
		return (DM_MT_CDR);
	case DK_CDRW:
		return (DM_MT_CDRW);
	case DK_DVDROM:
		return (DM_MT_DVDROM);
	case DK_DVDR:
		return (DM_MT_DVDR);
	case DK_DVDRAM:
		return (DM_MT_DVDRAM);
	case DK_FIXED_DISK:
		return (DM_MT_FIXED);
	case DK_FLOPPY:
		return (DM_MT_FLOPPY);
	case DK_ZIP:
		return (DM_MT_ZIP);
	case DK_JAZ:
		return (DM_MT_JAZ);
	default:
		return (DM_MT_UNKNOWN);
	}
}

/*
 * This function handles removable media.
 */
static int
get_rmm_name(disk_t *dp, char *mname, int size)
{
	int		loaded;
	int		fd;

	loaded = 0;

	if ((fd = drive_open_disk(dp, NULL, 0)) >= 0) {
		struct dk_minfo minfo;

		if ((loaded = media_read_info(fd, &minfo))) {
			struct extvtoc vtoc;

			if (read_extvtoc(fd, &vtoc) >= 0) {
				if (vtoc.v_volume[0] != NULL) {
					if (LEN_DKL_VVOL < size) {
						(void) strlcpy(mname,
						    vtoc.v_volume,
						    LEN_DKL_VVOL);
					} else {
						(void) strlcpy(mname,
						    vtoc.v_volume, size);
					}
				}
			}
		}

		(void) close(fd);
	}

	return (loaded);
}