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.
159 160 161 162 163 164 165 166 |
# File 'ext/shout.c', line 159 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
168 169 170 171 172 |
# File 'ext/shout.c', line 168 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.
175 176 177 178 179 180 181 |
# File 'ext/shout.c', line 175 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
342 343 344 345 346 347 348 |
# File 'ext/shout.c', line 342 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”.
521 522 523 524 525 526 527 528 529 530 531 |
# File 'ext/shout.c', line 521 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#close ⇒ Object
Disconnect from the server.
199 200 201 202 203 204 205 206 207 208 209 |
# File 'ext/shout.c', line 199 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.
186 187 188 189 190 191 192 193 194 195 196 |
# File 'ext/shout.c', line 186 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.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'ext/shout.c', line 214 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.
257 258 259 260 261 262 263 264 |
# File 'ext/shout.c', line 257 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
387 388 389 390 391 392 393 |
# File 'ext/shout.c', line 387 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.
591 592 593 594 595 596 597 598 599 600 601 |
# File 'ext/shout.c', line 591 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#disconnect ⇒ Object
Disconnect from the server.
199 200 201 202 203 204 205 206 207 208 209 |
# File 'ext/shout.c', line 199 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
333 334 335 336 337 338 339 |
# File 'ext/shout.c', line 333 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.
507 508 509 510 511 512 513 514 515 516 517 |
# File 'ext/shout.c', line 507 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#format ⇒ Object
315 316 317 318 319 320 321 |
# File 'ext/shout.c', line 315 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
480 481 482 483 484 485 486 487 488 489 490 |
# File 'ext/shout.c', line 480 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
378 379 380 381 382 383 384 |
# File 'ext/shout.c', line 378 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.
578 579 580 581 582 583 584 585 586 587 588 |
# File 'ext/shout.c', line 578 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#host ⇒ Object
getters
270 271 272 273 274 275 276 |
# File 'ext/shout.c', line 270 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.
407 408 409 410 411 412 413 414 415 416 417 |
# File 'ext/shout.c', line 407 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(value)->ptr); 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.
607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'ext/shout.c', line 607 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
324 325 326 327 328 329 330 |
# File 'ext/shout.c', line 324 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.
493 494 495 496 497 498 499 500 501 502 503 |
# File 'ext/shout.c', line 493 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#name ⇒ Object
360 361 362 363 364 365 366 |
# File 'ext/shout.c', line 360 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.”
552 553 554 555 556 557 558 559 560 561 562 |
# File 'ext/shout.c', line 552 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(value)->ptr); 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.
186 187 188 189 190 191 192 193 194 195 196 |
# File 'ext/shout.c', line 186 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
297 298 299 300 301 302 303 |
# File 'ext/shout.c', line 297 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.
446 447 448 449 450 451 452 453 454 455 456 |
# File 'ext/shout.c', line 446 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#password ⇒ Object
297 298 299 300 301 302 303 |
# File 'ext/shout.c', line 297 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.
446 447 448 449 450 451 452 453 454 455 456 |
# File 'ext/shout.c', line 446 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#port ⇒ Object
279 280 281 282 283 284 285 |
# File 'ext/shout.c', line 279 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.
420 421 422 423 424 425 426 427 428 429 430 |
# File 'ext/shout.c', line 420 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
306 307 308 309 310 311 312 |
# File 'ext/shout.c', line 306 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.
464 465 466 467 468 469 470 471 472 473 474 |
# File 'ext/shout.c', line 464 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
351 352 353 354 355 356 357 |
# File 'ext/shout.c', line 351 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.
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'ext/shout.c', line 535 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.
230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'ext/shout.c', line 230 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(to_send)->ptr), RSTRING(to_send)->len); 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.
246 247 248 249 250 251 252 |
# File 'ext/shout.c', line 246 static VALUE _sh_sync(VALUE self) { shout_connection *s; GET_SC(self, s); shout_sync(s->conn); return Qtrue; } |
#url ⇒ Object
369 370 371 372 373 374 375 |
# File 'ext/shout.c', line 369 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.
565 566 567 568 569 570 571 572 573 574 575 |
# File 'ext/shout.c', line 565 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#user ⇒ Object
288 289 290 291 292 293 294 |
# File 'ext/shout.c', line 288 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”.
433 434 435 436 437 438 439 440 441 442 443 |
# File 'ext/shout.c', line 433 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#user_agent ⇒ Object
342 343 344 345 346 347 348 |
# File 'ext/shout.c', line 342 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”.
521 522 523 524 525 526 527 528 529 530 531 |
# File 'ext/shout.c', line 521 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |
#username ⇒ Object
288 289 290 291 292 293 294 |
# File 'ext/shout.c', line 288 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”.
433 434 435 436 437 438 439 440 441 442 443 |
# File 'ext/shout.c', line 433 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(value)->ptr); if(err != SHOUTERR_SUCCESS) { raise_shout_error(s->conn); } return value; } |