Manage event GST_EVENT_CAPS

Change-Id: I9a12152eebf7137bf14c4557db10fa04e20c69a0
Fix internal data flow errors

We need to process segment events before receiving a buffer.

Change-Id: I272fe550cec4134c230a700dcbcea525607879b6