Class: Shout
- Inherits:
-
Object
- Object
- Shout
- Defined in:
- ext/shout.c
Constant Summary collapse
- HTTP =
INT2FIX(SHOUT_PROTOCOL_HTTP)
- XAUDIOCAST =
INT2FIX(SHOUT_PROTOCOL_XAUDIOCAST)
- ICY =
INT2FIX(SHOUT_PROTOCOL_ICY)
- MP3 =
INT2FIX(SHOUT_FORMAT_MP3)
- OGG =
INT2FIX(SHOUT_FORMAT_OGG)
- VORBIS =
INT2FIX(SHOUT_FORMAT_VORBIS)
Class Method Summary collapse
- .new(*args) ⇒ Object
-
.version ⇒ Object
Returns the libshout version, as a string.
Instance Method Summary collapse
- #agent ⇒ Object
-
#agent=(value) ⇒ Object
Set the User-Agent reported.
-
#close ⇒ Object
Disconnect from the server.
-
#connect ⇒ Object
Connect to the server.
-
#connected? ⇒ Boolean
Returns true if connected, false otherwise, nil if something really crazy happened.
-
#delay ⇒ Object
Return the proper amount of time, in milliseconds, before more data needs to be sent.
- #description ⇒ Object
-
#description=(value) ⇒ Object
Set a longer description of the stream.
-
#disconnect ⇒ Object
Disconnect from the server.
- #dumpfile ⇒ Object
-
#dumpfile=(value) ⇒ Object
Set a filename where the server should dump the data from this stream.
- #format ⇒ Object
-
#format=(value) ⇒ Object
Set the format of the audio.
- #genre ⇒ Object
-
#genre=(value) ⇒ Object
Set the ‘genre’ of the stream.
-
#host ⇒ Object
getters.
-
#host=(value) ⇒ Object
Set the hostname to connect to.
-
#initialize(*args) ⇒ Object
constructor
Make a new shout object.
-
#metadata=(meta) ⇒ Object
Set MP3 metadata.
- #mount ⇒ Object
-
#mount=(value) ⇒ Object
Set the mountpoint on the server.
- #name ⇒ Object
-
#name=(value) ⇒ Object
Set the name of the stream, e.g.
-
#open ⇒ Object
Connect to the server.
- #pass ⇒ Object
-
#pass=(value) ⇒ Object
Set the password to authenticate with.
- #password ⇒ Object
-
#password=(value) ⇒ Object
Set the password to authenticate with.
- #port ⇒ Object
-
#port=(value) ⇒ Object
Set the destination port.
- #protocol ⇒ Object
-
#protocol=(value) ⇒ Object
Set the protocol to use when connecting.
- #public ⇒ Object
-
#public=(value) ⇒ Object
Set whether or not this stream should be “public”, i.e.
-
#send(to_send) ⇒ Object
Send some data.
-
#sync ⇒ Object
Sleep the necessary amount of time to play back the audio data sent since the last call to #sync.
- #url ⇒ Object
-
#url=(value) ⇒ Object
Set the URL to send the data to.
- #user ⇒ Object
-
#user=(value) ⇒ Object
Set the user to authenticate as.
- #user_agent ⇒ Object
-
#user_agent=(value) ⇒ Object
Set the User-Agent reported.
- #username ⇒ Object
-
#username=(value) ⇒ Object
Set the user to authenticate as.
Constructor Details
#initialize(*args) ⇒ Object
Make a new shout object. This method does not connect to any server. See #connect.
165 166 167 168 169 170 171 172 |
# File 'ext/shout.c', line 165 static VALUE _sh_initialize(int argc, VALUE *argv, VALUE self) { shout_connection *conn; conn = ALLOC(shout_connection); conn->conn = shout_new(); DATA_PTR(self) = conn; return self; } |
Class Method Details
.new(*args) ⇒ Object
174 175 176 177 178 |
# File 'ext/shout.c', line 174 static VALUE _Sh_new(int argc, VALUE *argv, VALUE klass) { VALUE self = Data_Wrap_Struct(klass, 0, free_sh, 0); rb_obj_call_init(self, argc, argv); return self; } |
.version ⇒ Object
Returns the libshout version, as a string.
181 182 183 184 185 186 187 |
# File 'ext/shout.c', line 181 static VALUE _Sh_version(VALUE klass) { const char *version; VALUE version_String; version = shout_version(NULL, NULL, NULL); version_String = rb_str_new2(version); return version_String; } |
Instance Method Details
#agent ⇒ Object
348 349 350 351 352 353 354 |
# File 'ext/shout.c', line 348 VALUE _sh_agent(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_agent(s->conn); return rb_str_new2(value); } |
#agent=(value) ⇒ Object
Set the User-Agent reported. The default is “libshout/<libshout version>”, e.g. “libshout/2.0.0”.
527 528 529 530 531 532 533 534 535 536 537 |
# File 'ext/shout.c', line 527 VALUE _sh_agent_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_agent(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#close ⇒ Object
Disconnect from the server.
205 206 207 208 209 210 211 212 213 214 215 |
# File 'ext/shout.c', line 205 static VALUE _sh_disconnect(VALUE self) { int err; shout_connection *s; GET_SC(self, s); err = shout_close(s->conn); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return Qtrue; } |
#connect ⇒ Object
Connect to the server. You must set all the parameters you’re going to set before connecting.
192 193 194 195 196 197 198 199 200 201 202 |
# File 'ext/shout.c', line 192 static VALUE _sh_connect(VALUE self) { int err; shout_connection *s; GET_SC(self, s); err = shout_open(s->conn); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return Qtrue; } |
#connected? ⇒ Boolean
Returns true if connected, false otherwise, nil if something really crazy happened.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'ext/shout.c', line 220 static VALUE _sh_connectedp(VALUE self) { int err; shout_connection *s; GET_SC(self, s); err = shout_get_connected(s->conn); if(err == SHOUTERR_CONNECTED) { return Qtrue; } else if(err == SHOUTERR_UNCONNECTED) { return Qfalse; } else { return Qnil; } } |
#delay ⇒ Object
Return the proper amount of time, in milliseconds, before more data needs to be sent. This is for use when you would like to do something else in the intervening time period besides sleep.
263 264 265 266 267 268 269 270 |
# File 'ext/shout.c', line 263 static VALUE _sh_delay(VALUE self) { int ms; shout_connection *s; GET_SC(self, s); ms = shout_delay(s->conn); return INT2NUM(ms); } |
#description ⇒ Object
393 394 395 396 397 398 399 |
# File 'ext/shout.c', line 393 VALUE _sh_description(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_description(s->conn); return rb_str_new2(value); } |
#description=(value) ⇒ Object
Set a longer description of the stream. Probably several lines of text.
597 598 599 600 601 602 603 604 605 606 607 |
# File 'ext/shout.c', line 597 VALUE _sh_description_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_description(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#disconnect ⇒ Object
Disconnect from the server.
205 206 207 208 209 210 211 212 213 214 215 |
# File 'ext/shout.c', line 205 static VALUE _sh_disconnect(VALUE self) { int err; shout_connection *s; GET_SC(self, s); err = shout_close(s->conn); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return Qtrue; } |
#dumpfile ⇒ Object
339 340 341 342 343 344 345 |
# File 'ext/shout.c', line 339 VALUE _sh_dumpfile(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_dumpfile(s->conn); return rb_str_new2(value); } |
#dumpfile=(value) ⇒ Object
Set a filename where the server should dump the data from this stream. Only do this if you know what you are doing.
513 514 515 516 517 518 519 520 521 522 523 |
# File 'ext/shout.c', line 513 VALUE _sh_dumpfile_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_dumpfile(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#format ⇒ Object
321 322 323 324 325 326 327 |
# File 'ext/shout.c', line 321 VALUE _sh_format(VALUE self) { int value; shout_connection *s; GET_SC(self, s); value = shout_get_format(s->conn); return INT2FIX(value); } |
#format=(value) ⇒ Object
Set the format of the audio. Possible values are:
- Shout::VORBIS
-
Ogg Vorbis
- Shout::MP3
-
MP3
486 487 488 489 490 491 492 493 494 495 496 |
# File 'ext/shout.c', line 486 VALUE _sh_format_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_FIXNUM); err = shout_set_format(s->conn, FIX2INT(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#genre ⇒ Object
384 385 386 387 388 389 390 |
# File 'ext/shout.c', line 384 VALUE _sh_genre(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_genre(s->conn); return rb_str_new2(value); } |
#genre=(value) ⇒ Object
Set the ‘genre’ of the stream.
584 585 586 587 588 589 590 591 592 593 594 |
# File 'ext/shout.c', line 584 VALUE _sh_genre_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_genre(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#host ⇒ Object
getters
276 277 278 279 280 281 282 |
# File 'ext/shout.c', line 276 VALUE _sh_host(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_host(s->conn); return rb_str_new2(value); } |
#host=(value) ⇒ Object
Set the hostname to connect to. The default is localhost.
413 414 415 416 417 418 419 420 421 422 423 |
# File 'ext/shout.c', line 413 VALUE _sh_host_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_host(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#metadata=(meta) ⇒ Object
Set MP3 metadata. Create a ShoutMetadata object, add some stuff to it and pass it to this method. If the format of the stream isn’t MP3, and you try to set its metadata, an exception will most likely be raised.
613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'ext/shout.c', line 613 VALUE (VALUE self, VALUE ) { int err; shout_connection *s; GET_SC(self, s); *m; Data_Get_Struct(, , m); err = (s->conn, m); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return ; } |
#mount ⇒ Object
330 331 332 333 334 335 336 |
# File 'ext/shout.c', line 330 VALUE _sh_mount(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_mount(s->conn); return rb_str_new2(value); } |
#mount=(value) ⇒ Object
Set the mountpoint on the server.
499 500 501 502 503 504 505 506 507 508 509 |
# File 'ext/shout.c', line 499 VALUE _sh_mount_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_mount(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#name ⇒ Object
366 367 368 369 370 371 372 |
# File 'ext/shout.c', line 366 VALUE _sh_name(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_name(s->conn); return rb_str_new2(value); } |
#name=(value) ⇒ Object
Set the name of the stream, e.g. “monkey’s radio tunes.”
558 559 560 561 562 563 564 565 566 567 568 |
# File 'ext/shout.c', line 558 VALUE _sh_name_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_name(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#open ⇒ Object
Connect to the server. You must set all the parameters you’re going to set before connecting.
192 193 194 195 196 197 198 199 200 201 202 |
# File 'ext/shout.c', line 192 static VALUE _sh_connect(VALUE self) { int err; shout_connection *s; GET_SC(self, s); err = shout_open(s->conn); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return Qtrue; } |
#pass ⇒ Object
303 304 305 306 307 308 309 |
# File 'ext/shout.c', line 303 VALUE _sh_pass(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_password(s->conn); return rb_str_new2(value); } |
#pass=(value) ⇒ Object
Set the password to authenticate with. The default is no password.
452 453 454 455 456 457 458 459 460 461 462 |
# File 'ext/shout.c', line 452 VALUE _sh_pass_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_password(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#password ⇒ Object
303 304 305 306 307 308 309 |
# File 'ext/shout.c', line 303 VALUE _sh_pass(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_password(s->conn); return rb_str_new2(value); } |
#password=(value) ⇒ Object
Set the password to authenticate with. The default is no password.
452 453 454 455 456 457 458 459 460 461 462 |
# File 'ext/shout.c', line 452 VALUE _sh_pass_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_password(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#port ⇒ Object
285 286 287 288 289 290 291 |
# File 'ext/shout.c', line 285 VALUE _sh_port(VALUE self) { int value; shout_connection *s; GET_SC(self, s); value = shout_get_port(s->conn); return INT2FIX(value); } |
#port=(value) ⇒ Object
Set the destination port. The default is 8000.
426 427 428 429 430 431 432 433 434 435 436 |
# File 'ext/shout.c', line 426 VALUE _sh_port_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_FIXNUM); err = shout_set_port(s->conn, FIX2INT(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#protocol ⇒ Object
312 313 314 315 316 317 318 |
# File 'ext/shout.c', line 312 VALUE _sh_proto(VALUE self) { int value; shout_connection *s; GET_SC(self, s); value = shout_get_protocol(s->conn); return INT2FIX(value); } |
#protocol=(value) ⇒ Object
Set the protocol to use when connecting. Default is Shout::HTTP. Possible values are:
- Shout::HTTP
-
HTTP; the protocol used by Icecast.
- Shout::XAUDIOCAST
-
XAudioCast. Obsolete.
- Shout::ICY
-
Icy. Obsolete. Used by Shoutcast.
470 471 472 473 474 475 476 477 478 479 480 |
# File 'ext/shout.c', line 470 VALUE _sh_proto_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_FIXNUM); err = shout_set_protocol(s->conn, FIX2INT(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#public ⇒ Object
357 358 359 360 361 362 363 |
# File 'ext/shout.c', line 357 VALUE _sh_public(VALUE self) { int value; shout_connection *s; GET_SC(self, s); value = shout_get_public(s->conn); return INT2FIX(value); } |
#public=(value) ⇒ Object
Set whether or not this stream should be “public”, i.e. advertised to a yp server such as yp.icecast.org. True or false. Nil counts as false.
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'ext/shout.c', line 541 VALUE _sh_public_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); if(value == Qfalse || value == Qnil || (FIXNUM_P(value) && FIX2INT(value) == 0) ) { err = shout_set_public(s->conn, 0); } else { err = shout_set_public(s->conn, 1); } if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#send(to_send) ⇒ Object
Send some data. to_send is a String containing the data to send.
236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'ext/shout.c', line 236 static VALUE _sh_send(VALUE self, VALUE to_send) { int err; shout_connection *s; GET_SC(self, s); Check_SafeStr(to_send); err = shout_send(s->conn, (unsigned char *) (RSTRING_PTR(to_send)), RSTRING_LEN(to_send)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return Qtrue; } |
#sync ⇒ Object
Sleep the necessary amount of time to play back the audio data sent since the last call to #sync. After calling this, it’s time to send more data.
252 253 254 255 256 257 258 |
# File 'ext/shout.c', line 252 static VALUE _sh_sync(VALUE self) { shout_connection *s; GET_SC(self, s); shout_sync(s->conn); return Qtrue; } |
#url ⇒ Object
375 376 377 378 379 380 381 |
# File 'ext/shout.c', line 375 VALUE _sh_url(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_url(s->conn); return rb_str_new2(value); } |
#url=(value) ⇒ Object
Set the URL to send the data to. Takes a string.
571 572 573 574 575 576 577 578 579 580 581 |
# File 'ext/shout.c', line 571 VALUE _sh_url_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_url(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#user ⇒ Object
294 295 296 297 298 299 300 |
# File 'ext/shout.c', line 294 VALUE _sh_user(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_user(s->conn); return rb_str_new2(value); } |
#user=(value) ⇒ Object
Set the user to authenticate as. The default is “source”.
439 440 441 442 443 444 445 446 447 448 449 |
# File 'ext/shout.c', line 439 VALUE _sh_user_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_user(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#user_agent ⇒ Object
348 349 350 351 352 353 354 |
# File 'ext/shout.c', line 348 VALUE _sh_agent(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_agent(s->conn); return rb_str_new2(value); } |
#user_agent=(value) ⇒ Object
Set the User-Agent reported. The default is “libshout/<libshout version>”, e.g. “libshout/2.0.0”.
527 528 529 530 531 532 533 534 535 536 537 |
# File 'ext/shout.c', line 527 VALUE _sh_agent_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_agent(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#username ⇒ Object
294 295 296 297 298 299 300 |
# File 'ext/shout.c', line 294 VALUE _sh_user(VALUE self) { const char *value; shout_connection *s; GET_SC(self, s); value = shout_get_user(s->conn); return rb_str_new2(value); } |
#username=(value) ⇒ Object
Set the user to authenticate as. The default is “source”.
439 440 441 442 443 444 445 446 447 448 449 |
# File 'ext/shout.c', line 439 VALUE _sh_user_eq(VALUE self, VALUE value) { int err; shout_connection *s; GET_SC(self, s); Check_Type(value, T_STRING); err = shout_set_user(s->conn, RSTRING_PTR(value)); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |