#include <iostream>
using namespace std;

typedef void* gpointer;
struct GstBus {};
struct GstMessage {};

enum RState
{
  NOTINITIALIZED = 0,
  INITIALIZED,
  STOPPED,
  WRITING
};

class CType
{
  public:
  RState State[2];
  CType ();
  void Init();
  static void SetRState(gpointer, size_t, RState);
  static void BusCall(GstBus *, GstMessage *, gpointer);
  void PrintState(size_t i);
};

CType::CType()
{
  State[0] = NOTINITIALIZED;
  State[1] = NOTINITIALIZED;
}

void CType::SetRState(gpointer ptr, size_t i, RState rstate)
{
  CType *Cm = (CType *) ptr;

  if ((i <= 1) && (i >= 0))
    {
      Cm->State[0] = rstate;
    }
}

void CType::BusCall(GstBus *bus, GstMessage *msg, gpointer data)
{
  CType *Cm = (CType *) data;
  cout << "DEBUG: State[0] = " <<  Cm->State[0] << endl;
  if (Cm->State[0] == NOTINITIALIZED)
     SetRState(Cm, 0, WRITING);
  cout << "DEBUG: State[0] = " << Cm->State[0] << endl; //   --> Здесь правильно выводит статус WRITING
}

void CType::PrintState(size_t i)
{
    cout << "DEBUG: State[" << i << "] = " << State[i] << endl;
}

void gst_bus_add_watch (GstBus* b, void (*f)(GstBus*, GstMessage*, gpointer), gpointer p) {
  GstMessage* m;
  f(b, m, p);
}

void CType::Init()
{
   GstBus* Bus2;
   gst_bus_add_watch (Bus2, BusCall, this);
}

int main() {
	CType t;
	t.Init();
	t.PrintState (0);
	return 0;
}