SIP & SDP – Session Description Protocol

Protokołu SIP jest protokołem sygnalizacyjnym używanym do inicjowania sesji multimedialnych. SIP umożliwiają realizacje negocjacji charakterystyki sesji oraz jej aktualizacje ale sam w sobie nie zawiera mechanizmów do opisu kształtu sesji, przenoszonej za pomocą protkołu RTP. W tym celu SIP wykorzystuje protokół SDP (Session Descriptions Protocol)
wchodzący bezpośrednio w skład komunikatu. SDP zawiera informacje o rodzaju
mediów, kodekach i ich parametrach, adresach IP, kierunku strumieniów, dostępnym pasmie itp.

Opis sesji:

  • v= (protocol version) – wersja protokołu -> “0”
  • o= (originator and session identifier) – zrodlo i identyfikator sesji -> “dowolna_nazwa id_sesji wersja_sesji IN (IP4|IP6) adresIP_zródła_sesji”
  • s= (session subject) – temat sesjii -> “-“
  • i=* (session information) – opis sesji -> nie używany
  • u=* (URI of description) – uri dodatkowe opisu sesji -> nie używany
  • e=* (email address) – adres email osoby odpowiedzialnej za sesje -> nie używany
  • p=* (phone number) – numer telefoniczny osoby odpowiedzialnej za sesje -> nie używany
  • c=* (connection information) – opis połaczenia, nie wymagany jeśli obecny dla każdego strumienia mediów -> “IN (IP4|IP6) adresIP”
  • b=* (zero or more bandwidth information lines) – sugerowane pasmo -> nie używany
  • One or more time descriptions
  • z=* (time zone adjustments)- definicja strefy czasu -> nie używany
  • k=* (encryption key) – klucz szyfrujący -> nie używane
  • a=* (zero or more session attribute lines) – atrybuty: sendonly – jeśli strona tylko chce wysyłać media, recvonly – jeśli strona chce tylko odbierać media, inactive – bez mediów, sendrecv – jeśli strona chce wysyłać i odbierać media
  • Zero or more media descriptions

Opis Czasu:

  • t= (time the session is active) – czas sesji -> “0 0”
  • r=* (zero or more repeat times) – cykliczność sesji -> nie używany

Opis Mediów:

  • m= (media name and transport address) – opis mediów -> “(audio|video|text) RTP/AVP opis danych medialnych”
  • i=* (media title) – opis mediów -> nie używany
  • c=* (connection information) – opis połaczenia, nie wymagany jeśli obecny w opisie sesji, nadpisuje wartość z opisu sesji -> “IN (IP4|IP6) AdresIP”
  • b=* (zero or more bandwidth information lines) – sugerowane pasmo -> nie używany
  • k=* (encryption key) – klucz szyfrujący -> nie używane
  • a=* (zero or more media attribute lines)  – atrybuty strumienia, nadpisują atrybuty zdefiniowane w opisie sesji: sendonly – jeśli strona tylko chce wysyłać media, recvonly
    – jeśli strona chce tylko odbierać media, inactive – bez mediów,
    sendrecv – jeśli strona chce wysyłać i odbierać media, rtcp – port dla rtcp jesli nie, ptime – dlugosc mediów w sekunadach w przesylanym pakiecie, rtpmap – mapuje numer typu zawartosci do konkretnego kodeka i jego czestotliwosci, fmtp – umożliwia mapowanie parametrow tak aby sdp nie musialo tego rozumiec
You May Also Like

Inconsistent Dependency Injection to domains with Grails

I've encountered strange behavior with a domain class in my project: services that should be injected were null. I've became suspicious as why is that? Services are injected properly in other domain classes so why this one is different?

Constructors experiment

I've created an experiment. I've created empty LibraryService that should be injected and Book domain class like this:

class Book {
def libraryService

String author
String title
int pageCount

Book() {
println("Finished constructor Book()")
}

Book(String author) {
this()
this.@author = author
println("Finished constructor Book(String author)")
}

Book(String author, String title) {
super()
this.@author = author
this.@title = title
println("Finished constructor Book(String author, String title)")
}

Book(String author, String title, int pageCount) {
this.@author = author
this.@title = title
this.@pageCount = pageCount
println("Finished constructor Book(String author, String title, int pageCount)")
}

void logInjectedService() {
println(" Service libraryService is injected? -> $libraryService")
}
}
class LibraryService {
def serviceMethod() {
}
}

Book has 4 explicit constructors. I want to check which constructor is injecting dependecies. This is my method that constructs Book objects and I called it in controller:

class BookController {
def index() {
constructAndExamineBooks()
}

static constructAndExamineBooks() {
println("Started constructAndExamineBooks")
Book book1 = new Book().logInjectedService()
Book book2 = new Book("foo").logInjectedService()
Book book3 = new Book("foo", 'bar').logInjectedService()
Book book4 = new Book("foo", 'bar', 100).logInjectedService()
Book book5 = new Book(author: "foo", title: 'bar')
println("Finished constructor Book(Map params)")
book5.logInjectedService()
}
}

Analysis

Output looks like this:

Started constructAndExamineBooks
Finished constructor Book()
Service libraryService is injected? -> eu.spoonman.refaktor.LibraryService@2affcce2
Finished constructor Book()
Finished constructor Book(String author)
Service libraryService is injected? -> eu.spoonman.refaktor.LibraryService@2affcce2
Finished constructor Book(String author, String title)
Service libraryService is injected? -> null
Finished constructor Book(String author, String title, int pageCount)
Service libraryService is injected? -> null
Finished constructor Book()
Finished constructor Book(Map params)
Service libraryService is injected? -> eu.spoonman.refaktor.LibraryService@2affcce2

What do we see?

  1. Empty constructor injects dependencies.
  2. Constructor that invokes empty constructor explicitly injects dependencies.
  3. Constructor that invokes parent's constructor explicitly does not inject dependencies.
  4. Constructor without any explicit call declared does not call empty constructor thus it does not inject dependencies.
  5. Constructor provied by Grails with a map as a parameter invokes empty constructor and injects dependencies.

Conclusion

Always explicitily invoke empty constructor in your Grail domain classes to ensure Dependency Injection! I didn't know until today either!